Can't convert docx to PDF properly

Hi,

I am converting doc or docx to PDF using aspose.word.Document. There is some issue in margin while converting to PDF. I m attaching my both docx and converted PDF file in attachment. this is the code snipet:

com.aspose.words.Document doc = new com.aspose.words.Document(DocPath);
doc.save(PDFPath,SaveFormat.PDF);

Thanks in advance for ur valuable supportTestConversion.zip (27.9 KB)
TestConversion.pdf (104.4 KB)

@sheoran531994

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for Java 18.9 and have not found the shared issue. Please use Aspose.Words for Java 18.9. We have attached the output PDF with this post for your kind reference. 18.9.pdf (98.6 KB)

Thanks for the update.

There is file name in the footer. I wanted that file name should remain same as in docx file.
We have aspose.total license.

Thanks in advance

@sheoran531994

Thanks for your inquiry. Please use the following code example to get the desired output.

Document doc = new Document(MyDir + "TestConversion.docx");
for(HeaderFooter headerFooter : doc.getFirstSection().getHeadersFooters())
for(Field field : headerFooter.getRange().getFields())
{
    if(field.getType()== FieldType.FIELD_FILE_NAME)
        field.unlink();
}
doc.save(MyDir + "out.pdf");

Hi,

Thanks for your update. It is not working in my case. Can you please give me the input and output file.
Because in my case it is not coming inside the for(Field field : headerFooter.getRange().getFields()) loop.

Thanks in advance

@sheoran531994

Thanks for your inquiry. Please use the latest version of Aspose.Words for Java 18.9. We have attached the input and output documents with this post for your kind reference. Docs.zip (120.1 KB)

Thank you for your valuable support. I am using the old Aspose.word jar for java. Now it is working fine as i wanted.

@sheoran531994

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.