Pdf output different from docx output on document save

I am doing some heavy processing on a docx using Words for .net.

When the processing is done, I output the document with these lines:

line 368 = oDoc.Save("C:\Users\18300\Desktop\DocPdfDir.docx")

line 369 = oDoc.Save("C:\Users\18300\Desktop\DocPdfDir.pdf")

The docx is saved correctly, but the pdf looks like some of the processing has not been completed. The differences are on pages 13, 15 and 16. Page 13 should have a table, etc. Pages 15 and 16 have an index in which I have replaced the ': ' sequence with a tab (using Words).

If I just read the finalized docx file and then Save it, the pdf is fine.

Is there some closing of the document or maybe the builder that should be done to 'finalize' the document before creating the pdf?

Thanks for any help.

Hi Brad,

Thanks for your inquiry. I suggest you please upgrade to the latest version of Aspose.Words for .NET 14.8.0 and call Document.UpdatePageLayout before saving the Pdf file. This method formats a document into pages and updates the page number related fields in the document such as PAGE, PAGES, PAGEREF and REF. The up-to-date page layout information is required for a correct rendering of the document to fixed-page formats.

If you still face problem, please create a standalone/runnable simple application (for example a Console Application Project) that demonstrates the code you used to generate your output document and share it here for testing purposes along with input Word document. I will investigate the issue on my side and provide you more information.

Hi Tahir,

The Document.UpdatePageLayout call solved the problem.

Thanks for the answer.

Hi Brad,

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