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

Free Support Forum - aspose.com

Aspose.pdf (3.9) & Acrobat Reader 7 - "there was an error opening this document"


I am evaluating using aspose.pdf (v 3.9) to create PDF documents from Excel documents. The Excel documents are created using aspose.cells (v 4.3). As part of the evaulation, I ran into a problem displsying the PDFs under Acrobat Reader 7 (but not Adobe Reader 8 or 9) - I get the error
"there was an error opening this document".

When I used one of the online PDF analyzers (https://www.pdf-tools.com/osa/repair.aspx) to check the generated PDF, I see the following results:
The file is corrupt and cannot be repaired, but possibly recovered
Errors:
Open file.
0x80410108 - E - The end-of-file marker was not found.
0x8041010A - E - The 'startxref' keyword or the xref position was not found.
0x80410108 - E - The end-of-file marker was not found.
Close file.
A sample PDF (project_status.pdf) which does not display using Adobe Reader 7.1, but does display with Adobe Reader 9, is attached.

I am using the following code to convert the aspose.cells generated Excel file to a PDF:
MemoryStream ms = new MemoryStream();
workbook.Save(ms, FileFormatType.AsposePdf);

string fileName = string.Format("{0}.pdf", Title);
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(ms, null);

Is there a different way to generate the PDF from aspose.pdf so that it displays using Acrobat Reader 7 as well as Adobe Reader 8 & 9?

Hi,

Please try adding following line of code:

ms.Position = 0;

before this below line:

pdf.BindXML(ms,null);

I hope this is gonna solve your problem. If problem still persists, please do let us know so we could investigate further.

Regards,

I added the suggested line of code. It did not fix the problem. The generated PDF does not display in Acrobat Reader 7 ("there was an error opening this document"), but displays in Adobe Reader 9.

Is there a different way to generate the PDF from aspose.pdf so that it displays using Acrobat Reader 7 as well as Adobe Reader 8 & 9?

Thanks!

Hi,

There is no specific way for generating Pdf files that could be opened in any specific version of Acrobat reader. In fact, the procedure is same which generates the Pdf files that can be opened in any version of Adobe. Make sure you are using the latest version of Aspose.Pdf 3.9.0.0 and Aspose.Cells 4.6.0.0 and incase the issue still persists, please share the resource Excel file so that we can test the issue at our end.

We apologize for your inconvenience.

Upgrading to aspose.cells (v 4.6) did not fix the problem. A copy of the Excel file (project_status.xls) is attached.

Hi,

I’ve tested the issue and I am able to convert the Excel sheet into Pdf file. I am able to open the resultant Pdf file in Acrobat 5.0 and Acrobat 9.0. I’ve tested the issue with Aspose.Cells 4.6.0.0 and Aspose.Pdf 3.9.0.2.

The resultant Pdf file and latest hotfix for Aspose.Pdf 3.9.0.2 are in attachment. Please take a look. In case of any further issues, please feel free to contact.

What were the test results for Acrobat Reader 7.1?

(In your reply, you said you tested it with Acrobat 5.0 & 9.0. The problem I am having is with Acrobat Reader 7.1.)

I download the updated aspose.pdf (3.9.0.2). I still have the same problem displaying the PDF with Acrobat Reader 7.1 - "there was an error opening this document".

What should I look at next so I can generate PDFs for Acrobat Reader 7.1 & 9.0?

Hi,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I’ve again tested the issue with latest version of Aspose.Pdf 4.0.0 (which will be published soon) and Aspose.Cells 4.6.0.0 and I my test I am able to open the resultant file in Adobe Reader 7.1.0. The resultant Pdf file and the latest hotfix are in attachment, please take a look and try opening this file with your installed version of Adobe Reader.

I am using the following code snippet.

[C#]

//Get the template excel file path.

string designerFile = @"C:\Temp\project_status.xls";

//Specify the xml file path.

string xmlFile = @"C:\Temp\ExcelSentToAspose.xml";

//Specify the pdf file path.

string pdfFile = @"C:\Temp\project_status_7.1.0.pdf";

//Create a new Workbook.

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();

//Open the template excel file which you have to

//convert to pdf file.

wb.Open(designerFile);

//First, Save the xls file in xml file (Aspose.Pdf file format)

wb.Save(xmlFile, FileFormatType.AsposePdf);

//Create a new Pdf object.

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

//Now, Bind the xml file (Aspose.Pdf integrated), which

//is used as a medium file for conversion.

pdf.BindXML(xmlFile, null);

pdf.IsImagesInXmlDeleteNeeded = true;

//Save the pdf file.

pdf.Save(pdfFile);


In case of any further issues, please feel free to contact.

Thank you for the code sample. It was helpful in isolating the problem. I have a solution for what I am trying to do.

I was using the Pdf.Save() method to send the file to a web browser:
pdf.Save(fileName, Aspose.Pdf.SaveType.OpenInAcrobat, Response);
and this appears to be where the problem is. With the above line of code, I can display the PDF in Adobe Reader 9, but it will not display in Acrobat Reader 7.1.

Using Aspose.Cells (v 4.3) and Aspose.Pdf (v 3.9), I tried two different ways to send the PDF to the web browser.

This block of code does not work:
byte[] bytes;
using (MemoryStream msPdfToResponse = new MemoryStream())
{
pdf.Save(msPdfToResponse);
bytes = new byte[(int)msPdfToResponse.Length];
msPdfToResponse.Read(bytes, 0, (int)msPdfToResponse.Length);
}

Response.Clear();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment; filename=project_status.pdf");
Response.AddHeader("Content-Length", bytes.Length.ToString());
Response.ContentType = "application/pdf";
Response.BinaryWrite(bytes);
Response.End();

This block of code works:
byte[] bytes;
using (MemoryStream msPdfToResponse = new MemoryStream())
{
pdf.Save(msPdfToResponse);
bytes = msPdfToResponse.ToArray();
}

Response.Clear();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition","attachment; filename=project_status.pdf");
Response.AddHeader("Content-Length", bytes.Length.ToString());
Response.ContentType = "application/pdf";
Response.BinaryWrite(bytes);
Response.End();

Thanks for your help!