-1

document.xml document.docx here is the link for my document. I'm trying to convert the DOCX to PDF. I'm able to covert it, but i realize the text box in the DOCX is gone after converted to PDF. How can I solve this problem? Below is the code that how I convert to PDF.

String myFilePath = "testing.docx";

File docxFile = new File("testing.docx");
WordprocessingMLPackage wordprocessingMLPackage = WordprocessingMLPackage.load(docxFile);

Mapper identifierFontMapper = new IdentityPlusMapper();
wordprocessingMLPackage.setFontMapper(identifierFontMapper);

Mapper bestMatchingMapper = new BestMatchingMapper();
wordprocessingMLPackage.setFontMapper(bestMatchingMapper);

Docx4J.toPDF(wordprocessingMLPackage, new FileOutputStream(myFilePath + ".pdf"));
codingDummy
  • 122
  • 2
  • 14

1 Answers1

-1

I'm afraid docx4j's export-FO support for text boxes is not that great.

This is due in part to an impedance mismatch between Word's flexibility and the more limited options in XSL FO (eg you can float left or right, and a bit more).

See the comment at https://github.com/plutext/docx4j-export-FO/blob/master/src/main/java/org/docx4j/convert/out/fo/FOPictWriterAbstract.java#L50 for a summary of how Word's options map to FO.

As an alternative, you could try our commercial PDF Converter, at https://converter-eval.plutext.com/ which can do a better job with text boxes, since it does not use XSL FO.

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84