Skip to content

Commit

Permalink
Merge pull request #2128 from laws-africa/pdf
Browse files Browse the repository at this point in the history
update the matrix correctly when adjusting tables; add tests
  • Loading branch information
goose-life authored Jun 27, 2024
2 parents facea31 + 78740a1 commit 4ff120d
Show file tree
Hide file tree
Showing 5 changed files with 2,510 additions and 5 deletions.
12 changes: 7 additions & 5 deletions indigo_api/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,18 +403,20 @@ def resize_tables(self, doc):
for x in range(missing_cells):
log.debug(f"Adding missing cell in table {table.get('eId')} on row {y+1}")
row.append(doc.maker('td'))
# update the matrix
matrix[y][len(matrix[y])] = True
# update the matrix
for x in range(n_cols):
matrix[y][x] = True

# add colgroup element with each column and its width
column_widths = [0 for _ in range(n_cols)]
# offset also needs to take rowspans into account: update the matrix to be False for co-ordinates where
# a cell is not expected because of a rowspan on a previous cell
for y, row in enumerate(table.xpath('a:tr', namespaces={'a': doc.namespace})):
offset = 0
for x, cell in enumerate(row.xpath('a:th|a:td', namespaces={'a': doc.namespace})):
offset = 0
if not matrix[y][x]:
offset += 1
# take colspan into account to set False on the correct cell in the matrix
colspan = int(cell.get('colspan', '1'))
offset += colspan - 1
rowspan = int(cell.get('rowspan', '1'))
if rowspan > 1:
for r in range(rowspan - 1):
Expand Down
Loading

0 comments on commit 4ff120d

Please sign in to comment.