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.
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.
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.
Layers and hidden content
Boxes with a negative z-index sit behind the text, and visibility: hidden keeps its space without being written.
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.
OpenType features in Word
Ligatures, small capitals and figure styles from CSS font features are passed on as Word's own OpenType settings.
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.

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.
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.
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.
