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

Free Support Forum - aspose.com

Load a PDF document with PdfFileInfo | Aspose.PDF for .NET | Poor Performance while loading the document

We are experiencing very very poor performance, it actually pegs the CPU and never completes, attempting to load a PDF from a System.IO.Stream into the PdfFileInfo object.

It hangs and never completes this line of code:

PdfFileInfo fileInfo = new PdfFileInfo(docStream);

This only seems to happen on certain PDF documents that contain images, e.g. a scanned document so it only contains the images of each page. The number of pages does not seem to have anything to do with it as I’ve reproduced it using a 1 page PDF document that is an image.
f799e558-dcfa-4a6d-b9f5-82c6a29d30e0_0.pdf (4.4 MB)

Update: seems to be having the same problem trying to load it into a Aspose.Pdf.Document object.

@jgullickson

We have tested the scenario in our environment using Aspose.PDF for .NET 20.6 and were unable to notice slow loading issue. The API took 2 seconds to load the document from stream. Would you kindly make sure to test the scenario with latest version of the API and if issue still persists at your end, please share your environment details i.e. RAM Size, OS Name and Version, Application Type, .NET Framework Version, etc. We will test the scenario in our environment and address it accordingly.

Hi, thanks for the fast response.

I upgraded Aspose.PDF from 19.9 to 20.6 and am still seeing the issue. The same document I linked in my original post hung for 20 minutes before I killed it.

The App is .Net Core 2.1 it runs in in an Azure App Service with an I3 App Service Plan (840 total ACU with 14GB of ram).

We’re reading the file from a form post in our API and passing the document stream to the Aspose.PDF code to check for password protected PDFs. Here’s some sample code.
In the API controller:

var file = Request.Form.Files[i]; //this happens in a loop for all uploaded files

using (var stream = file.OpenReadStream())
{
if (FileUploadValidator.IsPdfEncrypted(stream))
throw new System.ArgumentException(“PDF is password protected. Please remove password protection and try again.”);
}

The class that does the check for password: (the bolded line is where it hangs)

public static bool IsPdfEncrypted(Stream fileStream)
{
try
{
PdfFileInfo info = new PdfFileInfo(fileStream);

            if (info.HasOpenPassword)
            { return true; }
            else
            { return false; }
        }
        catch (Exception ex)
        {
            return true;
        }

    }

Thanks

@jgullickson

Thanks for providing further details.

We have logged an investigation ticket as PDFNET-48422 in our issue tracking system to further investigate this scenario. We will look into reasons behind this behavior of the API and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.