TiffDevice.Process(...) hanging/infinite loop

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

@jgullickson

Thank you for contacting support.

Would you please share a sample PDF document which does not work, and the other version of it as well from Corel Draw so that we may try to reproduce it in our environment and proceed further. Before sharing requested data, please ensure using Aspose.PDF for .NET 19.9.

The documents contain user PII that I’m unable to share unfortunately. I would need to redact the PII before sharing. I’m looking for a way to do that now. Any suggestions? I fear that any attempt to alter the document will render the document unusable for this test.

redactedcopy_willnotprocess.pdf (4.6 MB)

I’ve uploaded a redacted copy of the pdf that won’t process. I am using the latest version of Aspose.PDF 19.9.

corel.pdf (1008.8 KB)

This is the version of the document that was opened and saved in Corel. It processes in a few seconds.

@jgullickson

Thank you for sharing requested data.

Please note that forum attachments are accessible to thread owner and Aspose staff only. Moreover, a ticket with ID PDFNET-47108 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

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