Free Support Forum - aspose.com

Page problem converting Word document to Pdf

Hello,

I have a problem converting a Word File to Pdf using Aspose.Words 6.3.0.0 and Aspose.Pdf 4.0.0.0.

The source Word document has three pages. After the conversion, my newly created Pdf document has four pages.

The Word document contains several images and lots of tables.

I need to get a Pdf document, having exactly the same number of pages than the source Word file.

The following code is used for the conversion process:

----------------------------

Aspose.Words.Document document = new Aspose.Words.Document(fullFileNameSource);

document.SaveOptions.PdfExportImagesFolder = temporaryFilesDirectory;

document.Save(cacheFileNameXml, Aspose.Words.SaveFormat.AsposePdf);

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();

pdf.IsImagesInXmlDeleteNeeded = true;

pdf.IsTruetypeFontMapCached = true;

pdf.TruetypeFontMapPath = temporaryFilesDirectory;

pdf.BindXML(cacheFileNameXml, null);

pdf.Save(fullFileNameTarget);

----------------------------------------------------

Thank four your help,

Boris

Hello Boris,

Can you please share the source word document that you're using so that we can test the scenario at our end. We apologize for your inconvenience.

Hello Nayyer,

thank you for your fast reply.

I attached the source word document to this post.

Hello Boris,

Thanks for sharing the resource document.

I've tested the scenario using Aspose.Pdf for .NET 4.2.1 and Aspose.Words for .NET 8.0.0 and I'm unable to notice the problem. The resultant PDF contains the exact number of pages as the source word document (the last page is not converted because it doesn't contain any information inside the page body except for the Header and Footer section). The resultant PDF that I've generated is in attachment, please take a look.

You can download Aspose.Pdf for .NET 4.2.1 from 226952.

FYI, In recent versions of Aspose.Words, a new method of saving word document directly into PDF format is introduced which does not require Aspose.Pdf to complete the job. For more related information, please visit How-to: Convert a Document to PDF

In case it does not satisfy your requirements or you've any further query, please feel free to contact.

We apologize for your inconvenience.

Hello Nayyer,

Now I' ve tried both ways to convert the Word document with the new versions of Aspose.Words and Aspose.Pdf. Now it works perfect.

Thank you very much for your fast support.