Pages are corrupt or too many pages

Hi, we are getting the following error when trying to extract the first page image from a pdf file. This is the code:

Aspose.Pdf.Kit.PdfConverter converter = new Aspose.Pdf.Kit.PdfConverter();
converter.BindPdf(uploadDocument.UploadedFiles[0].InputStream);
converter.StartPage = 1;
converter.EndPage = 1;
converter.DoConvert();
if (converter.HasNextImage())
{…
The error happens on the HasNextImage() line, stack trace:
[IOException: pages are corrupt or too many pages]
Aspose.Pdf.Kit.PdfConverter.HasNextImage() +256
Admin_Contacts_Profiles.gvDocuments_InsertCommand(Object source, GridCommandEventArgs e) in C:\Projects\MySystem\SmashFly WebSites\SmashFly\Admin\Contacts\Profiles.aspx.cs:1168
The problem is not in the pdf file because it uploads fine in dev and staging, but for some reason
throws this error in production. When we first upgraded to the latest version of the aspose dlls
we started getting this error in dev, but then just replacing all dlls with the new set helped us fix it.
In production there are only 3 aspose dlls, Pdf.kit, Words and Slides, same as in dev (I searched the entire server), 
so I ran out of ideas what else could be causing this issue.
Versions:
Pdf.kit - 3.4.0.0
Slides - 2.8.4.0
Words- 6.3.0.0
Please help!
Thanks
Filipp

Forgot to mention the product versions:

Pdf.kit - 3.4.0.0
Slides - 2.8.4.0
Words- 6.3.0.0
Thanks!

Hi Filipp,

Thank you very much for considering Aspose.

Are you using 64-bit machine in production environment?

Regards,

Hi, thank you for getting back to me so quickly,

no, the machine is 32 bit, W2003.

Hi Filipp,

I have tested the code on Windows 2003 EE using the hotfix 3.4.4.1, and couldn't see any issue. Please download the hotfix from this link and try it at your end. If you still find any problem please share the PDF file you're having issue with.

We're sorry for the inconvenience.

Regards,

The new dll resolved that issue! But, the processing time is much slower and the image quality is much worse. The CPU usage has also gone way up!


Is this a debug version of the dll, it is twice the size the old one? May be a release version would run faster? Also, would I need to use any new flags to improve the quality of the output?


Thank you!
Filipp

Hi Filipp,

Thanks for the feedback.

The feature of converting PDF to image in the dll (v3.4.4.1) is still in beta phase, and we will try to improve the functionality and the performance of the feature before we publishing new release. And the interface will be kept the same as previous version's, so there would be no new flags to be used.

Thanks,

Could you please give me an estimated date of the next release? We can’t publish it to production the way it is, so if we are talking months then we will need a different solution.


Thank you

Hi,

The next release will be published at the end of this month.

Thanks,

Hello,


I’m having this same problem, but in an odd situation. I use the same code to print a PDF via a FileStream using the Aspose.Pdf.Kit.PdfViewer via an ASP.NET 2.0 C# application and a C# 2.0 Window Service. The process works great via the ASP.NET application, but the Window Service gives me the “Pages are corrupt or too many pages” error. Will this not work for Windows Services? I’m using Aspose.Pdf.Kit v 3.3

Here is my code:

///
/// Prints a pdf document with an already specified printer
///
public static void PrintPdf(Stream fileStream, string printerName)
{
GrabLicense();

PdfViewer viewer = new PdfViewer();
viewer.OpenPdfFile(fileStream);
PrinterSettings ps = new PrinterSettings();
ps.PrinterName = printerName;
viewer.AutoRotate = true;

viewer.PrintDocumentWithSettings(ps);
viewer.ClosePdfFile();
}

using (DataSet dsPdf = PrintingServiceDAO.getImage(printedDocId.ToString()))
{
if (dsPdf.Tables[0].Rows.Count > 0)
{

//Grabs DocumentImage from Database
byte[] pdfByteArray = (byte[])dsPdf.Tables[0].Rows[0][“DOCUMENT_IMAGE”];

if (myByteArray.Length > 0)
{
//Put in MemoryStream
using (MemoryStream msPdf = new MemoryStream(myByteArray))
{
PrintDoc(msPdf, Path.GetExtension(documentName), printerName);

}
}
}
}

private static void PrintDoc(Stream fileStream, string extension, string printerName)
{
try
{
//If PDF - then Re-print, go to general drawer
if (extension.ToLower() == “.pdf”)
{
PrintQueue.PrintPdf(fileStream, PrintQueue.PrinterTypes.PHYSICIAN_STATEMENTS_REPRINT,
Util.ConfigPath + Util.ConfigFileName);
}
else if (extension.ToLower() == “.doc”)
{
if (string.IsNullOrEmpty(printerName))
{
PrintQueue.PrintDoc(fileStream, PrintQueue.PrinterTypes.PHYSICIAN_STATEMENTS,
Util.ConfigPath + Util.ConfigFileName);
}
else
{
//Printer Specified
PrintQueue.PrintDoc(fileStream, printerName);
}
}
}
catch (Exception ex)
{
Util.log.WriteEntry(string.Format(“Error Printing Statement - PrintDoc() Message:{0}”, ex.Message), EventLogEntryType.Information, 554);
}
}

Hi Matt,

First off, please try to use the latest merged Aspose.Pdf for .NET 6.2.0. We have merged Aspose.Pdf.Kit into Aspose.Pdf for .NET. You can find all the Aspose.Pdf.Kit classes under Aspose.Pdf.Facades namespace. Aspose.Pdf.Kit for .NET will be discontinued from October 2011.

If the latest version still doesn’t resolve your issue then please share the sample project along with the input PDF file with us, so we could investigate the issue at our end. You’ll be updated with the results accordingly.

We’re sorry for the inconvenience.
Regards,