Skip to content

Feat: Add Word to PDF (.docx) - #15

Merged
Deityhub merged 2 commits into
devfrom
feat/word-to-pdf
Nov 7, 2026
Merged

Deityhub merged 2 commits into
devfrom
feat/word-to-pdf

Conversation

@Deityhub

@Deityhub Deityhub commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Description

Adds Word to PDF, a new tool that saves a .docx as a PDF on the user's device (nothing is uploaded). Ream reads the document and lays the pages out itself, so the Word preview in the other tools and the saved file come from the same converter.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Style/UI update (no functional changes)
  • ♻️ Code refactoring (no functional changes)
  • ⚡ Performance improvement
  • ✅ Test update
  • 🔧 Configuration change
  • 🏗️ Build/CI update

Changes Made

  • New tool word-to-pdf (manifest, run.ts, panel with the Fonts panel, page text for search engines), registered with the other tools. The old Word preview now uses it.
  • Layout: headers and footers with page numbers (restarts, formats, odd and even pages), widow and keep-with-next control, footnotes and endnotes, columns (balanced before continuous breaks), table styles with borders, repeated header rows and split rows, tab stops with leaders, pictures in a line, placed with text around them and cropped.
  • Links, bookmarks (headings) and a table of contents that jumps to its pages and shows real page numbers (second layout pass).
  • Fonts stored in the document are used automatically; the Fonts panel lists the ones that are not.
  • PDF engine: link and jump annotations and bookmarks in PdfDrawing; faster text measuring (word widths cached).
  • Reader hardening: lengths that are not numbers or absurd are cleaned, and the layout loop always moves on (a damaged header once made it loop for ever).
  • Docs: AGENTS.md (milestone M8, reader and layout notes), panel note and FAQ.

Testing

Typecheck, 888 unit tests, build, seo-check and the notices check all pass locally. A few hundred deliberately damaged copies of real and generated documents were also converted: none hung or crashed, each gave a PDF or a clear error.

Unit Tests

  • All existing unit tests pass
  • Added new unit tests for new functionality

Manual Testing

  1. Open the Word to PDF tool, drop a .docx (for example one exported from Google Docs) and check the live preview.
  2. Click Save as PDF, open the result and check headers, footers, links and bookmarks.
  3. Try a document with columns, footnotes or a table of contents.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

  • Output was never compared with Microsoft Word itself, only with Quick Look, Chrome's viewer and pypdf, so page breaks and spacing can differ slightly. Two judgement calls could not be checked: extra line spacing around inline pictures, and where "relative to paragraph" starts.
  • Not supported (stated in the panel and FAQ): .doc files, right-to-left and complex scripts, shapes other than pictures and text boxes, equations, comments and tracked changes, and text wrapped round a picture's outline.

Headers, footers and page numbers, clickable links, heading bookmarks, and
widow, keep-lines and keep-with-next control. PdfDrawing gains links and
bookmarks; the Word preview and the new tool share one converter.
Footnotes and endnotes, columns with balancing and continuous sections,
table styles with borders, header rows and split rows, tab stops with
leaders, bookmarks and a table of contents with real page numbers, odd
and even headers, page number restarts, inline and cropped pictures,
embedded fonts, and safer reading of damaged files.
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

@Deityhub Deityhub changed the title Add Word to PDF (.docx) Feat: Add Word to PDF (.docx) Nov 7, 2026
@Deityhub
Deityhub merged commit ea73b52 into dev Nov 7, 2026
3 checks passed
@Deityhub
Deityhub deleted the feat/word-to-pdf branch November 7, 2026 18:15
@Deityhub Deityhub mentioned this pull request Nov 7, 2026
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.

1 participant