We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose convert doc to pdf loosing header margin for the document header

I am trying to convert my word document (.doc) to PDF and its loosing the margin that is set to the image in the page header.

Please find attached sample word file that I am trying to convert and the result word document.

Code used to convert doc file to pdf:

public void convertDoc(String source, String destination) throws Exception {
    	this.initialise(getLicenseURL(), source);
    	Document doc = new Document(source);

**here the source is my word document and the destination is the file location for output pdf

DemoDoc.docx (61.8 KB)
OutputPDF.pdf (31.1 KB)
Header Difference.png (56.0 KB)

I am really stuck in this issue. Any help would be appreciated.

@visaninasir As I can see you are using old version of Aspose.Words 16.12 on your side. I cannot reproduce the problem on my side using the latest 21.11 version of Aspose.Words for Java. Please see the output document produced on my side.out.pdf (32.0 KB)
So, please try using the latest version of Aspose.Words.

Hello @alexey.noskov ,

Thank you for the solution. Since I am using this Aspose.Words 16.12 for my current project since long and its a huge change for me to just update the jar as the testing efforts are more if I update the jars.

for example one of the change that is required is:

For 16.12
    String body = document.toTxt().trim()

For 21.11
    String body = document.toString().trim()

And along with that I am also facing issues with the license as the license that I have is the older one and works with the older version only :frowning_face:

Is there any other solution for this issue I am facing?

@visaninasir Unfortunately, we do not provide support for old versions of Aspose.Words. All fixes and improvements are provided in newer versions.
You can try checking expiration date of your license and update to the latest version covered by your subscription. Every Aspose license carries one-year subscription for free upgrades to new versions released during this time. To check an expiration date of your license open the license file using notepad. You will see the following tags:


It means that you can free upgrade to version of Aspose.Words published before 02/18/2011.