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

Free Support Forum - aspose.com

Aspose hangs processing corrupted PDF file

Our client is using Aspose PDF, the file Aspose.Pdf.dll, version 2015.01.12 (10.0.0.0). During processing certain currupted PDF files the multiple functions just hang. Normal files and some other corrupted files are processed in reasonable time.
He asked me to check if the newest version is Ok for processing this file. Unfortunately it hangs similarly.

Example of the file can be taken from here: https://www.dropbox.com/s/0v59nct3m6rbwn1/9e05d271-3017-4631-8631-d76b57a5e5dd.pdf?dl=0
Example of code we used in particular like this:
private static int PDFToPDF(string fileName, Aspose.Pdf.Document pdfDocument)
{
try
{
Console.WriteLine($@“Read source document from {Path.GetFileName(fileName)}”);

            var sourcePdf = new Document(fileName);
            var device = new TextDevice(new TextExtractionOptions(TextExtractionOptions.TextFormattingMode.Raw));
            foreach (Page page in sourcePdf.Pages)
            {
                pdfDocument.Pages.Add(page);
                device.Process(page, Stream.Null);
            }
            Console.WriteLine(@"The source document has been processed");
            return 0;
        }
        catch (Exception exception)
        {
            Console.WriteLine(exception.Message);
            return exception.Message.Contains("password") ? 1 : 2;
        }

    }

@alexandre8n8

Thank you for contacting support.

The PDF file shared by you is not a valid PDF file so Aspose.PDF API can not load it properly. Few files that appear corrupt like this one, are processed fine because all corrupt files must have different reasons for being invalid. They are not necessarily corrupt the same way this specific PDF file is. So, we are afraid this file may not be processed with Aspose.PDF API.

Farhan, I hope very much that you can read again my message. The problem that ASPOSE decides if this file correct or not correct TOO LONG. That is the problem. We want to know, if the incoming file is OK or NOT OK.
We cannot do it because ASPOSE just hangs TOO Long. Some other incorrect files aspose can process and we get exception, we would be happy if this could be possible with many other wrong files. Currently with some files it is possible, with other files the application JUST HANGs.

@alexandre8n8

The validity of a PDF file can be checked with IsPdfFile property, as in the code snippet below. However, this too is taking too long. Therefore, we have logged an investigation ticket with ID PDFNET-44717 in our issue management system. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

PdfFileInfo info = new PdfFileInfo(fileName);
bool flag = info.IsPdfFile;
Console.WriteLine(flag);

We are sorry for the inconvenience.