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

Free Support Forum - aspose.com

Error occurs at new Aspose.Pdf.Document

Hello team,

I try to convert xxxx.pdf to image using Aspose 18.2.0.0 however error occurs at new Aspose.Pdf.Document(docStream) and exception happens at new Aspose.Pdf.Devices.Resolution().

Exception message is as follows.
“Cross reference table or cross reference stream not found”

N0025.zip (373.8 KB)

This is the file and code.

try {
    string inputFile = "c:\\work\\N0025.pdf";
    using(MemoryStream docStream = new MemoryStream(File.ReadAllBytes(inputFile)))
    {
        // Read PDF files
        Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(docStream);

        for (int i = 1; (i <= pdfDoc.Pages.Count) && (i <= this.config.DocumentMaxPageNumber); i++)
        {
            var resolution = new Aspose.Pdf.Devices.Resolution(this.config.ImageReadDpi);
            var bmpDevice = new Aspose.Pdf.Devices.BmpDevice(resolution);

            // Export image file
            using (MemoryStream bmpStream = new MemoryStream())
            {
                bmpDevice.Process(pdfDoc.Pages[i], bmpStream);
                using (Bitmap bitmap = new Bitmap(bmpStream))
                {
                    string imgFile = string.Format(@"{0}_{1:d}.jpg", inputFile, i);
                    bitmap.SetResolution(this.config.ImageWriteDpi, this.config.ImageWriteDpi);
                    bitmap.Save(imgFile, this.config.JpegEncoder, this.config.EncoderParameters);
                }
            }
        }
    }
}
catch (System.Exception ex)
{
    Console.WriteLine(ex.Message);
}

@PFU.DSOL2

Thank you for contacting support.

I have worked with the data shared by you and have been able to reproduce Cross Reference Table Exception in our environment. A ticket with ID PDFNET-44283 has been logged in our issue management system for further investigation and resolution. The issue ID has been linked with this thread so that you will receive notification as soon as the issue is resolved.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-44283) have been fixed in Aspose.PDF for .NET 20.7.