Word templates and save as PDF

Hi,

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

Attached the document I used.

Kind Regards
Ibbe

Hi
Ibbe,

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.

Best Regards,

Hi Awais,

I downloaded the the latest version, 11.2.0.0 and still get the same result.

I downloaded Aspose.Total_dll_only.

Attached you can find the DLL i used.

Kind Regards

Ibbe

Hi Ibbe,

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.

Best Regards,

Hi
Ibbe,

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:

I hope, this will help.

Best Regards,

Hallo Awais,

I contacted our customer about the “Buged” word document.
After some searching on their part they found the problem.

But even with a modified template they still got the same result.

Attached their new word document.

Kind regards,

Ibbe

Hi Ibbe,

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.

I hope, this will help.

Best Regards,

Hallo Awaisv,

This solution, actually it is a workaround, will not work for us.

We use the conversion of Word to PDF as blackbox function in our software.

We don’t know that it is a standard word document or a word document generated by a mail merge.

We just convert the document to PDF so our viewer can display it.

Also all the information is present in de word document , a mailmerge should not be performed.

It is the conversions that is bugged.

Kind regards

Ibbe

Hi Ibbe,

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.

Best Regards,

Hallo Awaisv,

You are correct if I use the original document.

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”

Kind Regards

Ibbe

Hi Ibbe,

Thanks for the additional information.

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.

Best Regards,

Hi Ibbe,

Thanks for your inquiry.

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.

Thanks,

The issues you have found earlier (filed as WORDSNET-6223) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.