Skip to content

Commit

Permalink
fix #308: ignore parsing page
Browse files Browse the repository at this point in the history
  • Loading branch information
greendreamer authored and green0317 committed Sep 23, 2024
1 parent fb05d6c commit f8516f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pdf2docx/table/Cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def make_docx(self, table, indexes):
n_row, n_col = self.merged_cells
i, j = indexes
docx_cell = table.cell(i, j)
if n_row*n_col!=1:
if n_row*n_col != 1 and ((i+n_row-1) * table._column_count + j+n_col-1) < len(table._cells): # check whether index is over length of cells
_cell = table.cell(i+n_row-1, j+n_col-1)
try:
docx_cell.merge(_cell)
Expand Down Expand Up @@ -133,7 +133,8 @@ def _set_style(self, table, indexes):
# merged cells are assumed to have same borders with the main cell
for m in range(i, i+n_row):
for n in range(j, j+n_col):
docx.set_cell_border(table.cell(m, n), **kwargs)
if len(table._cells) > m * table._column_count + n: # check whether index is over length of cells
docx.set_cell_border(table.cell(m, n), **kwargs)

# ---------------------
# cell bg-color
Expand Down
5 changes: 4 additions & 1 deletion pdf2docx/table/Row.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def make_docx(self, table, idx_row:int):
# to control the layout precisely, set `exact` value, rather than `at least` value
# the associated steps in MS word: Table Properties -> Row -> Row height -> exactly
docx_row.height_rule = WD_ROW_HEIGHT.EXACTLY


if self.height < 0: # to prevent negative height validation
self.height = 0

# NOTE: row height is counted from center-line of top border to center line of bottom border
docx_row.height = Pt(self.height)

Expand Down

0 comments on commit f8516f9

Please sign in to comment.