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

Free Support Forum - aspose.com

Extract text and access PDF Layers in C# with Aspose.PDF for .NET - Memory consumption is large


when extracting text from attached pdf using the following code memory allocation of e.g. a 64bit test console is increasing up to 12GB and extraction is never finished.

static void ExtractTextFromPDF()
            Aspose.Pdf.License lic = new Aspose.Pdf.License();
            Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(@"c:\@@tmp\Layers_1.pdf");

            TextAbsorber textAbsorber = new TextAbsorber();

            textAbsorber.ExtractionOptions.FormattingMode = TextExtractionOptions.TextFormattingMode.Raw;
            // Just the same....


        static void Main(string[] args)
            catch (Exception ex)
                Console.WriteLine("Workingset: {0}", System.Diagnostics.Process.GetCurrentProcess().WorkingSet64);

Aspose_Memory.png (24.0 KB)

Another issue:
I am not able to access layers of the document using Page.Layers property. Page.Layers is always null.
Had this behaviour for all documents I checked.

    foreach (Aspose.Pdf.Page page in pdf.Pages)
        if (page.Layers != null) //page.Layers is always null!!
            // do something

I was not able to upload example PDF (22MB).

Best Regards


Would you kindly upload the sample document to Google Drive or Dropbox and share the link with us. We will test the scenario in our environment and address it accordingly.

I put one example file on DropBox:


Thanks for sharing the sample PDF.

We were able to reproduce both issues in our environment during testing the scenario with Aspose.PDF for .NET 20.2 and logged them in our issue tracking system as following:

  • PDFNET-47696 - Related to memory consumption
  • PDFNET-47697 - Related to access layers

We will surely look into details of these issues and keep you informed with their resolution status. Please be patient and spare us little time.

We are sorry for the inconvenience.