Hello,
I have an application that is converting user uploaded PDFs to Tiff images and we are using the TiffDevice.Process() to unpack and add each page of the PDFs to a frame in the Tiff image. For some PDFs this process seems to enter an endless loop and will process until we terminate it. In some cases over 20 hours. In one case the document is only 3 pages, however, like all the other PDFs that have experienced this problem they only contain images. As in a document was scanned and an image for each page was added to a PDF as a page. One commonality of the offending PDFs each document was apparently generated using the GPL Ghostscript 9.06 library. What is odd is that when we opened the PDF in Corel Draw and exported it then processed the PDF it worked fine, whatever the issue was was removed in that import/export process.
//load pdf stream into PdfFileInfo
PdfFileEditor pdfEditor = new PdfFileEditor();
PdfFileInfo fileInfo = new PdfFileInfo(docStream);
//new code to unpack pdf and create tiff
Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.Depth = ColorDepth.Format1bpp;
tiffSettings.Compression = CompressionType.LZW;
tiffSettings.SkipBlankPages = true;
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
Document pdfDoc = new Aspose.Pdf.Document(docStream);
using (MemoryStream pdfPageOutput = new MemoryStream())
{
tiffDevice.Process(pdfDoc, 1, fileInfo.Document.Pages.Count, pdfPageOutput);
pdfPageOutput.Position = 0;
TiffImage tiffImage = (TiffImage)Aspose.Imaging.Image.Load(pdfPageOutput);
mainImage.Add(tiffImage);
if (firstRun) //we removed intitial frame that is blank
{
firstRun = false;
mainImage.ActiveFrame = mainImage.Frames[1];
mainImage.RemoveFrame(0);
}
mainImage.Save();
}