Saving DOC or DOCX file to PDF doesn't give same result as MS Word save as PDF

Hi there!

I have a problem actually and cannot find where it comes from…! My application output the “report” in DOCX or PDF format. Some of the photos in the report are cropped in the PDF and are not (which is OK) in the DOCX.

If I take the resulting DOCX and open it and save it as PDF with Aspose Words, photos are not correct. Here’s the code:

Dim doc As New Document(dataDir & "Rapport.docx")
doc.Save(dataDir & "generated.pdf", SaveFormat.Pdf)

If I open the same previously resulting DOCX in MS WORD and just save it as PDF file, everything is OK.

In attachment:

Resulting DOCX (Report.docx)
PDF generated by saving as PDF in MS WORD

PDF generated by Aspose Words using this code:

Dim doc As New Document(dataDir & "Rapport.docx")
doc.Save(dataDir & "generated.pdf", SaveFormat.Pdf)

Any clue?

Thanks and have a nice day,

JSr

Hi,

Thanks for your inquiry.

While using the latest version of Aspose.Words i.e. 13.1.0, I managed to reproduce this issue on my side. I have logged this issue in our bug tracking system. The issue ID is WORDSNET-7750. Your request has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Moreover, I would suggest you please use the following code as a temporary workaround:

Document doc = new Document(@"C:\Temp\Report.docx");
doc.UpdateTableLayout();
doc.Save(@"C:\temp\out.pdf");

I hope, this helps.

Best regards,

Wow!

Thanks a lot. This workaround is working well!
I can’t thank you as much as I would like to!

Great, great, really great support. Each time I’m facing a problem, you’re there.

Good product and keep on good work!

Have a nice day,

JSr

Hi,

Thanks for your feedback. Please let us know any time you have any further queries. We are always glad to help you.

Best regards,

Hi there!

I applied the workaround and everything works fine when I have 1 or 2 photos. Now, when I have 3, 5, 7, etc. photos, the last one is not centered.

Once again, everything is OK when saving to DOCX format but not when saving to PDF format.

If I open the saved DOCX in MS WORD 2010 and save it as PDF, everything is fine too and photos are centered.

NOTE: If I remove the “doc.UpdateTableLayout()” before saving to PDF, everything is OK and photos are aligned in PDF too. But I need the UpdateTableLayout() (or if you have any other suggestions) to resolve my first issue.

I’ve attached those files:

Report.DOCX - File generated by aspose.
Generated with MS Word 2010.PDF - PDF created from Report.DOCX with MS WORD 2010
Generated with Aspose Words.PDF - PDF created Report.DOCX with Aspose.Words

Best Regards,

JSr

Hi,

Thanks for your inquiry.

You do not need to use the work around code from here in every case. You do not normally need to call UpdateTableLayout method as cell and table widths are maintained automatically. You can call this method before exporting to PDF (or any other fixed-page format), only in rare cases where you confirmed that tables appear incorrectly laid out in the output document. Calling this method might help to correct the output. But, it is not guaranteed that this will do the trick in every scenario. In this case, I would suggest you please use the two liner code from here and wait for the fix to your first issue i.e. WORDSNET-7750. We apologize for any inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSNET-7750) have been fixed in this Aspose.Words for .NET 18.11 update and this Aspose.Words for Java 18.11 update.