I want to create a document from an existing Word 2010 document and convert it to PDF using docx4j 3.1.0. I've built upon the sample in
The Word document already contains a header with text and an image that I do not modify in my processing. The resulting PDF document, however, doesn't contain the header.
Is this someting that is supposed to work? If yes: how can I find out what I am missing?
Yes, if you can see the header when you "save as PDF" in Word, then you should also see the header in docx4j's PDF output.
To have it fixed, we'll need to see the docx.
Just for the curious reader: the specific cause for the missing header turned out to be a wrong approach of setting page margins on the document. Instead of modifiying the existing settings via
body.getSectPr().getPgMar() (or even simpler: setting it in the template right away), the code created new
PageDimensions and set a new
SectPtr on the body, thereby somehow overwriting or removing the header.