Skip to content

Pagination: oversized tables with colspan (but no rowspan) are clipped instead of split at row boundaries #807

Description

@karlei-irving

Summary

PaginationEngine.trySplitSimpleOversizedTable rejects any table containing [colspan]:

table.querySelector("table, [rowspan], [colspan], [data-footnote-id]")

A colspan is horizontal merging, contained entirely within a single row — and this splitter only ever cuts between rows, so a row-boundary split can never break one. createSimpleTableFragment already clones the colgroup and whole rows (row.cloneNode(true)), so colspans travel intact with their cells.

The practical impact is large for legal/business documents: a very common document shape is a multi-page table whose section-header rows span all columns (w:gridSpan). Any such table taller than one page takes the whole-block overflow fallback — all rows land in a single page box whose .page-content has overflow: hidden, so everything past the first page-height is rendered but invisible. In our repro (landscape page, 25-row table, 7 header rows with colspan, zero rowspan), 17 rows were silently hidden; Word paginates the same file to 6 pages.

Repro

  1. Create a .docx: US Letter landscape, one table of ~25 rows spanning several pages, a few full-width section-header rows (w:gridSpan across all columns), no vertical merges (w:vMerge).
  2. convertDocxToHtml(bytes, { paginationMode: 1 }) + paginateHtml(html, container).
  3. Observe totalPages far below Word's count, one page whose .page-content has scrollHeight ≈ N× clientHeight, and rows past the first page-height invisible.

Suggested fix

Drop [colspan] from the reject selector (keep [rowspan], which genuinely can cross a row-boundary split):

table.querySelector("table, [rowspan], [data-footnote-id]")

We've been running this one-token change as a local patch on 12.6.2: the repro table splits into row groups across 6 pages, each fragment re-measured and fitting, colspan header rows rendering correctly on their pages. Happy to send a PR if useful.

Related observation

The same document also exposes that w:tblInd (here a negative indent, -725 twips, which Word uses to spread an over-wide table across both page margins) is not carried into the emitted table CSS (margin-left: 0px), so a table wider than the text column is clipped by the content box in paginated mode where Word shows it in full. Can file separately if you'd like it tracked.

Thanks for the library — the tracked-changes and legal-numbering fidelity is excellent.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions