Skip to content

Commit

Permalink
change back to original codes and set remark
Browse files Browse the repository at this point in the history
  • Loading branch information
dothinking committed Jan 19, 2024
1 parent 293fb7c commit 45587dd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pdf2docx/page/RawPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def parse_section(self, **settings):
if not elements: return

# to create section with collected lines
lines = Collection()
lines = Collection()
sections = []
def close_section(num_col, elements, y_ref):
# append to last section if both single column
Expand Down Expand Up @@ -229,10 +229,10 @@ def close_section(num_col, elements, y_ref):
if current_num_col!=pre_num_col:
# process pre-section
close_section(pre_num_col, lines, y_ref)
if sections:
if sections:
y_ref = sections[-1][-1].bbox[3]

# start potential new section
# start potential new section
lines = Collection(row)
pre_num_col = current_num_col

Expand All @@ -254,7 +254,9 @@ def _create_section(num_col:int, elements:Collection, h_range:tuple, y_ref:float

if num_col==1:
x0, y0, x1, y1 = elements.bbox
column = Column((X0, y0, X1, y1))
# Note: do not use Column((X0, y0, X1, y1)) directly here. We have to set final bbox
# per update_bbox to avoid double rotation in case page rotation exists.
column = Column().update_bbox((X0, y0, X1, y1)) # this is final bbox, must use update_bbox
column.add_elements(elements)
section = Section(space=0, columns=[column])
before_space = y0 - y_ref
Expand All @@ -264,10 +266,10 @@ def _create_section(num_col:int, elements:Collection, h_range:tuple, y_ref:float
m0, n0, m1, n1 = cols[1].bbox
u = (u1+m0)/2.0

column_1 = Column((X0, v0, u, v1))
column_1 = Column().update_bbox((X0, v0, u, v1))
column_1.add_elements(elements)

column_2 = Column((u, n0, X1, n1))
column_2 = Column().update_bbox((u, n0, X1, n1))
column_2.add_elements(elements)

section = Section(space=0, columns=[column_1, column_2])
Expand Down

0 comments on commit 45587dd

Please sign in to comment.