Free Support Forum - aspose.com

Getting color type from pdf page is extremely slow

Getting the color type (black/white, grayscale or color) from a pdf page is really slow. It takes almost 10 seconds before the property gets resolved in a c# program on Visual Studio 2017. It doesn’t matter if it’s a big file or a small file.

I am using Aspose.PDF version 18.7

code example:

Page page = document.Pages[pageNr];
ColorType colorType = page.ColorType;

Is this normal?

@it.vandenbroele.be

Thank you for contacting support.

Would you please share the source PDF file while mentioning the page number you are checking the color of, as well as the code snippet you are using to measure time consumption so that we may try to reproduce and investigate it in our environment. Before sharing requested details, please ensure using Aspose.PDF for .NET 18.8.

Gladly,

the code snippet (using system.diagnostics.stopwatch in c#):

public static ColorType GetColorTypeByPage(Document document, int pageNr)
    {            
        var page = document.Pages[pageNr];
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.Start();
        ColorType colorType = page.ColorType;
        stopwatch.Stop();
        Console.WriteLine("time passed: " + stopwatch.Elapsed);            

        return colorType;
    }

one example page:

besluitPdfP2.pdf (56.8 KB)

@it.vandenbroele.be

Thank you for sharing requested data.

We have been able to reproduce the issue in our environment. A ticket with ID PDFNET-45299 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.

Thank you for logging the ticket!

We’re having an extra issue concerning the slowliness of the get color functionality. While requesting the colortype of a pdf we now experience out of memory exceptions.

When debugging we noticed a significant spike in memory usage when requesting the colorType from a pdf page. The longer this process runs, the more memory it demands. A nice example is using larger pdf files like blueprints. At some point it has to use more than all available memory, leading to the out of memory exception.

I see the issue hasn’t been adressed yet. So maybe this bit of extra info will help?

Kind regards

@it.vandenbroele.be

Thank you for sharing additional information.

This will definitely help us while addressing the issue. Can you please share a sample blueprints PDF file that you are referring to, by uploading it to Google Drive, Dropbox etc so that we may test and access the scenario even better.