Skip to content

fix: pdf table header alignment issue - #2259

Merged
Philipinho merged 2 commits into
docmost:mainfrom
Mayank-2-16:fix/pdf-table-header-alignment-issue
Jun 17, 2026
Merged

Philipinho merged 2 commits into
docmost:mainfrom
Mayank-2-16:fix/pdf-table-header-alignment-issue

Conversation

@Mayank-2-16

Copy link
Copy Markdown
Contributor

Summary

Fixes #2248.

This PR fixes table header alignment in PDF/print output. Table headers could appear shifted down when exporting or previewing a page as PDF.

The issue was caused by PDF rendering reusing the normal read-only editor extension setup, which includes interactive table behavior intended for screen viewing. In particular, table header pinning and readonly table sorting can add sticky/relative positioning, transforms, chevrons, and extra header padding. Those behaviors are useful in the browser, but they should not affect static PDF output.

This PR adds a print-specific render mode for ReadonlyPageEditor and uses it from the dedicated PDF render page. In that mode, the editor skips the interactive table header extensions so tables render as static document content for PDF generation.

Changes

  • Added an optional printMode prop to ReadonlyPageEditor.
  • When printMode is enabled, ReadonlyPageEditor excludes:
    • tableHeaderPin
    • tableReadonlySort
  • Updated the PDF render page to pass printMode when rendering page content for PDF export.
  • Added print CSS safeguards to:
    • reset pinned table header positioning during print
    • remove table header transforms during print
    • hide readonly sort chevrons in print output
    • restore normal header padding when sort chevrons are hidden

Why This Approach

PDF output should be static and deterministic. Interactive table features such as sticky headers and sort controls are screen-only behavior, and they can interfere with browser print layout.

Instead of changing table behavior globally, this PR scopes the behavior change to the PDF render path. Normal page editing and normal read-only page viewing are preserved.

This keeps the fix narrow:

  • editing behavior is unchanged
  • normal readonly table sorting is unchanged
  • normal table header pinning is unchanged
  • PDF/print output no longer inherits interactive table UI behavior

The print CSS fallback is included to make browser print and Save as PDF more robust in case any table header pin/sort styles are already present when print media styles are applied.

Manual Testing

Tested manually with a page containing a table with a real header row and body rows.

Verified:

  • Table headers align correctly in PDF/print preview.
  • Table headers are no longer shifted down in PDF output.
  • Normal page viewing remains unaffected.
  • Normal editor behavior remains unaffected.

Also ran:

pnpm --filter client build

The client build passed successfully.

Notes

This PR intentionally does not modify the server-side HTML/Markdown export service because the reported issue is in the browser PDF/print rendering path, not in HTML or Markdown export serialization.

@Philipinho
Philipinho merged commit 1867aa8 into docmost:main Jun 17, 2026
@Philipinho

Copy link
Copy Markdown
Member

Thanks for your contribution.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Table headers shifted down in PDF export

2 participants