Skip to content

[Layout fidelity] Cumulative pagination drift vs Word/PDF in DC template (section/table spacing and page break mismatch) #3261

@leandrotcawork

Description

@leandrotcawork

Summary

When rendering the DC template DOCX in SuperDoc (Layout Engine ON), pagination drifts cumulatively compared to Word/PDF.
This is not an isolated section-05 bug; vertical drift appears earlier and accumulates until page boundaries diverge.

Impact

This is a source-of-truth fidelity issue for enterprise/legal documents where section starts and page boundaries must match Word/PDF output.

Fixture

  • Document: DC_Template_Descricao_Cargo.docx
  • Baseline: Word export / PDF of same DOCX
  • SuperDoc mode: Layout Engine ON (DomPainter visible output)

Observed mismatch

  • In Word/PDF, section 05 continues on page 3.
  • In SuperDoc, section 05 is fully consumed on page 2, and page 3 starts at section 06.
  • Drift continues in later pages (section/page starts do not align with Word/PDF).

Repro steps

  1. Open DC_Template_Descricao_Cargo.docx in SuperDoc with Layout Engine ON.
  2. Compare pages 2-4 with Word/PDF export of the same DOCX.
  3. Observe that post-table spacing and section start positions are higher in SuperDoc than Word/PDF.
  4. Observe page-break divergence (notably around sections 05/06 and later sections).

Expected

SuperDoc page composition (section starts, table-to-heading spacing, page breaks) should match Word/PDF for this fixture.

Actual

SuperDoc produces less vertical consumption across repeated sections/tables, causing cumulative upward drift and earlier section starts.


What we investigated

1) Renderer/path ownership

  • Confirmed with Layout Engine ON that visible output is DomPainter path.
  • Drift is present in layout snapshot data before final paint, so this is not only a paint-layer issue.

2) Whole-document behavior

  • Section 05 was initially used as a visible example, but analysis of the whole document shows cumulative drift from earlier sections.
  • Repeated sections with similar table structures show repeated interval under-spacing.

3) Structural evidence

  • Rows/cells are present; this is not a missing table rows ingestion issue.
  • The issue behaves like vertical measurement/accounting mismatch rather than dropped content.

4) OOXML signal identified

  • Fixture contains w:docGrid w:linePitch="360" (24px at 96dpi).
  • Hypothesis: Word grid-aware vertical behavior is not fully reflected end-to-end in SuperDoc measurement/layout for this scenario.

5) Attempted fix branch status

  • A local PR investigation branch attempted constrained propagation/measurement changes.
  • Visual parity was still not fully achieved end-to-end.
  • I intentionally did not keep this as an upstream PR candidate.

Artifacts / archive

Screenshot package (Word vs SuperDoc)

  • Individual files:
  • Superdoc:
Image Image Image - Word: Image Image Image

DC_Template_Descricao_Cargo.docx


Environment

  • OS: Windows
  • Local validation date: May 13, 2026
  • Rendering mode: Layout Engine ON

Request

Please triage as a layout-fidelity bug (Word/PDF parity) with emphasis on cumulative vertical accounting across repeated table/section structures, not only the section-05 boundary symptom.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions