We use Aspose to convert Word documents to PDF.
One of our customers found a problem after upgrading to a newer version of our product.
They use templates to generate word documents in Navision and we convert and display them. After the update the data in het header of the document is not displayed, you only see fields of the template.
Code used as test:
Document doc = new Document("The Cannon Group PLC_S_QUOTE_240.doc");
doc.Save("C:\\word2.pdf", SaveFormat.Pdf);
I tested following versions of Aspose Words:
8.2.1.0: no problems
9.7.0.0: Header fields not displayed correctly
11.1.0.0: Header fields not displayed correctly
Thanks for your inquiry. While using the latest version of Aspose.Words i.e. 11.2.0, I was unable to reproduce this issue on my side. I would suggest you please upgrade to the latest version of Aspose.Words. I hope, this will help.
Thanks for the additional information. I finally managed to reproduce this issue on my side. I have logged this issue in our bug tracking system as WORDSNET-6185 . Your request has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.
During investigating your issue, we’ve found that your input Word document contains MergeFields with field values. When you save this document to PDF by using MS WORD, you’ll observe the same output as produced by Aspose.Words. This is not actually a bug and Aspose.Words does the right thing in this case. Moreover, I think, you should simply perform MailMerge operations for inserting values in the merge fields as described below before saving to PDF:
Thanks for your inquiry. As suggested in my previous reply, please try performing MailMerge operation before saving the document to PDF format. Below is the code for executing simple mail merge for the first two mergefields in your document:
Document doc = new
Document(@"C:\test\NEW_The+Cannon+Group+PLC_S_QUOTE_240.doc");
doc.MailMerge.Execute(
new string[] { "Company_Information_Name", "CAPTION_Company_Information_Name_2" },
new object[] { "CRONUS International Ltd.", "Naam 2" });
doc.UpdateFields();
doc.Save(@"c:\test\out.pdf");
Moreover, I have attached the PDF file i.e. generated on my side here for your reference.
Thanks for the additional information. But, could you please try converting your documents to PDF by using MS WORD itself. You’ll observe the same behaviour. Aspose.Words page layout engine tries to mimic the way the Microsoft Word’s page layout engine works. To you, this means that if you convert a Microsoft Word document into PDF, XPS or print it using Aspose.Words, the output will appear almost exactly as if it was done by Microsoft Word.
But if I use the document provided in my post from yesterday than the conversion to PDF by MS Word is flawless. The document is called “NEW_The Cannon Group PLC_S_QUOTE_240.doc”
While using the latest version of Aspose.Words i.e. 11.2.0, I managed to reproduce this issue on my side. I have logged this issue in our bug tracking system as WORDSNET-6223. Your request has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.
As a all purpose work around for the time being you can convert any merge fields in the document to static text before conversion to PDF. Please see the article here for details: Aspose.Words for .NET|Documentation
This would avoid any issues you are having for the time being until the root issue is fixed.