1
votes

I need to convert a docx to pdf and I am using docx4j-3.2.1 library for it. There is some format loss in the generated pdf output.

My input docx fileenter image description here

And the output pdf is this enter image description here

As can be seen clearly there are two notable issues. One is the size/dimension of image in the header that is reduced in generated pdf. It does not cover the full header area as is there in input.

Second is the font size which seem to have changed(or perhaps the font itself is changed)

How can I retain the dimension of original image on header in the generated pdf. Are there some methods that can be used to fine tune the conversion of docx to pdf.

Any help is greatly appreciated.

PS : The header image is taken from Google image search for header just for demonstration.

1
Okay there is some improvement when I changed the layout properties from MS-WORD by having the position of header as relative to page now. Earlier it was absolute.Aditya Bahuguna

1 Answers

0
votes

Docx4j v3.2.1 provides "cheap and cheerful" docx to PDF output via XSL FO.

If it is not good enough for you, you have 3 options:

  1. enhance it to do what you want
  2. use Plutext's commercial PDF Converter, which has its own page layout model, designed to closely mimic Word's,
  3. use some other product, perhaps LibreOffice + JOD Converter