Skip to main content
The PDF is painted from the same layout that the editor and the PNG export use. Text stays text: it is selectable and searchable, and the fonts are embedded as subsets.

Node: one call

toPdf(path?) returns the bytes too, so you can stream them instead of writing a file:

Node: show tracked changes and comments

toPdf paints the final view by default, as Word prints with No Markup. To print the redline (insertions underlined, deletions struck through, comments in a margin), pass the review view, with the same names and values as the docserver page images:
In the balloons view, a balloon that does not fit the margin is cut and marked ... [n]. Its full text prints on extra pages after the body, as Word prints it. Any other value throws, so a misspelled option never prints the final view by mistake. Simple Markup and Original are not offered. A review view has its own layout. Printing it does not lay out again the pages that getPageCount and the default toPdf read. After an edit, the next print of the same view lays out only what changed. toPng takes the same two options. To print without WordDocument, use the pipeline and set the view:
The PDF embeds the faces that the layout measured.

Browser

For a redline PDF in the page, pass trackedChanges: "inline" and comments: "balloons" to browserLayoutHost.

Without OfficeJS

If you only convert and do not edit, lay out the bytes and paint the result:
renderPdfInBrowser fetches the fallback face before it paints, so a missing glyph still has a face to embed.

Options

toPdf and renderPdfBytes take RenderPdfOptions; node toPdf also takes trackedChanges and comments (above):

Accuracy

Each release is checked page by page against PDFs that Microsoft Word exports, on a corpus of real documents. The layout follows Word’s rules for line breaks, tables, floats, footnotes, fields and section breaks. To see what one document uses and how well we support each feature, inspect it before you render:
Results depend on fonts. With the portable profile, line breaks match Word’s when the document uses Office fonts that have a metric clone (Calibri, Cambria, Arial, Times New Roman, Courier New, Georgia, Segoe UI). See Fonts.