WORD OUTPUT · DOCX AND RTF

Word documents that look like the PDF and stay editable.

Contracts, offers and reports often have to go out as a PDF and as a Word file that people can still edit. With the v42 engine, PD4ML writes DOCX and RTF from the same layout as the PDF: the same page breaks, columns and positioned content, written as native Word objects.

The v40 engine benefits too: PD4ML 4.1.1 rebuilt large parts of its DOCX output, and 4.2 brings watermarks and exact font sizes.

Formats
DOCX (DMS, UA) · RTF (PRO and up)
Layout
Taken from the PDF (v42)
Fonts
Embedded in the DOCX
Accessibility
Tagged Word documents (UA)
Reference
Microsoft Word
Same layout
as the PDF
Editable
shapes, text and controls
Fonts
travel with the file
Watermarks
in DOCX and RTF
Accessible
Word with the UA edition
NEW IN 4.2

Word output from the PDF's layout.

Editable Word objects

Positioned content, form controls, SVG and rounded boxes become Word shapes and controls you can still edit, not flattened pictures.

v4.2v42 engine

Columns side by side

CSS multi-column sections are written as Word columns with their gaps and rules, also when they continue over several pages.

v4.2v42 engine

Layers and hidden content

Boxes with a negative z-index sit behind the text, and visibility: hidden keeps its space without being written.

v4.2v42 engine

Fonts in the document

With pd4ml.docx.embed.fonts, the document's fonts are embedded, so the file looks the same on a machine that doesn't have them.

v4.2v42 engine

OpenType features in Word

Ligatures, small capitals and figure styles from CSS font features are passed on as Word's own OpenType settings.

v4.2v42 engine

Watermarks

"CONFIDENTIAL" or "DRAFT" now reaches DOCX and RTF. With v40 it is Word's own editable watermark; with v42 it is drawn exactly as in the PDF.

v4.2both engines
The pd4ml.com front page converted to DOCX, open in Microsoft Word: the layout matches the PDF, and the headline, buttons and navigation are editable text
The same conversion written as DOCX and opened in Microsoft Word: the layout matches the PDF, and the text stays editable. Download the DOCX.
THE DOCX OVERHAUL OF 4.1.1

Word files that open cleanly and look right.

PD4ML 4.1.1 reworked DOCX output for the v40 engine, and the fixes are in every later release.

  • Documents with tables in some styles open in Word again.
  • Spacing is kept: line spacing and the space before and after paragraphs.
  • Block styles survive: borders, backgrounds and padding, including sidebars whose background covers the whole block.
  • Headers and footers show on the first page, and headers and footers built as tables are rendered as one table.
  • Table header rows repeat on every page.
  • Images are embedded and sized to fit the page width, as in RTF output.
  • <br> is a real line break, so the line before it is no longer stretched to full width.
  • Since 4.2, font sizes are rounded to the half point, so 12pt text is no longer written as 11pt.
ONE PARSE, SEVERAL FORMATS

PDF for the archive, Word for the editor.

Read and lay out the HTML once, then write as many formats as you need. There is no second parse and no second template.

Sizes follow the PDF: the Word document gets the same scale as the page, and physical units can be kept true to size.

PD4ML pd4ml = new PD4ML();
pd4ml.useHtmlRenderer(Constants.LayoutEngine.v42);
pd4ml.setParam("pd4ml.docx.embed.fonts", "true");
pd4ml.readHTML(new FileInputStream("offer.html"));

pd4ml.writePDF(new FileOutputStream("offer.pdf"));    // for the customer
pd4ml.writeDOCX(new FileOutputStream("offer.docx"));  // for sales to edit
pd4ml.writeRTF(new FileOutputStream("offer.rtf"), false);

Features marked v4.2 are part of the PD4ML v4.2.0 development snapshot: download it from the Downloads page or use 4.2.0-SNAPSHOT from the Maven repository. The other features are in the current releases, PD4ML v4.1.2 and v4.0.24. The release notes and What Is New in PD4ML v4.2.0 list every change.

MORE IN PD4ML 4.1 AND 4.2

Explore the other improvements

Send PDF and Word from one template.

Download PD4ML and convert one of your documents to PDF and DOCX with a free evaluation license.