You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Guilhermo (JIRA)" <ji...@apache.org> on 2019/06/25 13:25:00 UTC

[jira] [Created] (PDFBOX-4580) PDFTextStripper::getText() lead to OutOfMemoryError: Java heap space

Guilhermo created PDFBOX-4580:
---------------------------------

             Summary: PDFTextStripper::getText() lead to OutOfMemoryError: Java heap space
                 Key: PDFBOX-4580
                 URL: https://issues.apache.org/jira/browse/PDFBOX-4580
             Project: PDFBox
          Issue Type: Bug
    Affects Versions: 2.0.15
            Reporter: Guilhermo
         Attachments: ceh.pdf

I just discovered a memory issue (Java heap space) that happen only if we try to use stripper.getText(pdfFile) on a pdf that has missing incorporated fonts (like the one in attachment).{color:#cc7832}
{color}

 

To replicate the issue you can use this snippet with the pdf file in attachment:

 
{code:java}
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;

import java.io.IOException;
import java.io.InputStream;

public class OutOfMemoryExample {

    public static void main(String[] args) throws IOException {

        try(InputStream docStream = Thread.currentThread().getContextClassLoader().getResource("ceh.pdf").openStream();
            PDDocument cd = PDDocument.load(docStream)){

            PDFTextStripper stripper = new PDFTextStripper();
            
            // OutOfMemory here
            String  pdfText = stripper.getText(cd);

            System.out.println(pdfText);
        }

    }
}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org