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);
}