We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Saving word document as PDF cannot be open in Adobe Acrobat Reader DC

Hi, recently we have upgraded Aspose.Words for .NET to version 17.9.0.0. We are using version for 3.5 .NET framwork.
There is problem when document is saved as PDF file. File can be open with Windows reader, on in browser, but when we try to open document with Adobe Acrobat Reader DC following error is displayed: “There was an error opening this document. The file is damaged and could not be repaired.”
In code we are creating document form word template and we are using merge fields to populate template. After merge document is saved as doc or pdf.
Doc document is open without any problems, but pdf document cannot be open in Adobe reader. Please see attached files (template, doc and pdf) AsposeProblem.zip (94.9 KB)

We have also tried to use latest version of Aspose.Words (18.2.0.0) with same results.
Could you please check what is the problem, this is big issue for our users.

Example:
MemoryStream outputStream = new MemoryStream();
switch (reportType)
{
case ReportDocumentType.Doc:
this.document.Save(outputStream, SaveFormat.Doc);
break;
case ReportDocumentType.Pdf:
this.document.Save(outputStream, SaveFormat.Pdf);
break;
}

        return Convert.ToBase64String(outputStream.GetBuffer());

@milanVr,

Please upgrade to the latest version of Aspose.Words for .NET 18.2 and see how it goes on your end? Hope, this helps.

In case the problem still remains, please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end, ZIP it and upload the ZIP file here for testing. We will investigate the issue further on our end and provide you more information. Thanks for your cooperation.

Thank you for your prompt response.
Unfortunately we have already tested generation with Aspose.Words for .Net 18.2.0.0 and problem exist in that version too.
Im am uploading simple solution for merging just a few fields where problem exist. This solution has only basic functionality form our word/pdf generation. And document generated with this code cannot be open in Adobe Acrobat reader. Please note that due limitation of attachment size Aspose.Words.dll is removed from solution, in example we have used version 18.2.0.0.
AsposeProblem.zip (20.9 KB)

Please note: We have analysed generated file and we have noticed that end of pdf file does not have proper ending. Instead of ending file with ‘%%EOF’ there are a lot of trailing bytes with 0 (nul value) value (Please check memory stream after file is generated). Once these trailing bytes are removed document can be open in Adobe Acrobat reader.

@milanVr,

In your private byte[] GetDocumentForSave() method, please use

return outputStream.ToArray();

Hope, this helps.

Thank you for your response.

This seems to solve the problem.
Thank you for your assistance.

A post was split to a new topic: PDF produced by Aspose.Words cannot be opened in Adobe Acrobat DC