You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Rodrigo Ferrari (JIRA)" <ji...@apache.org> on 2012/08/17 16:27:38 UTC

[jira] [Created] (PDFBOX-1389) Multy thread access to pdf generate erros

Rodrigo Ferrari created PDFBOX-1389:
---------------------------------------

             Summary: Multy thread access to pdf generate erros
                 Key: PDFBOX-1389
                 URL: https://issues.apache.org/jira/browse/PDFBOX-1389
             Project: PDFBox
          Issue Type: Bug
          Components: Text extraction
    Affects Versions: 1.7.1
         Environment: Windows/Linux
            Reporter: Rodrigo Ferrari


When working with a PDF that need to be accessed by multiple threads and execute operations to extract the text by region, to avoid the waiting time, it give me a few of warnings and exceptions.

2012-08-17 11:06:23 WARN  org.apache.pdfbox.util.PDFStreamEngine     - java.lang.NullPointerException
java.lang.NullPointerException
	at org.apache.pdfbox.util.operator.SetGraphicsStateParameters.process(SetGraphicsStateParameters.java:50)
	at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:556)
	at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:270)
	at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:237)
	at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:217)
	at org.apache.pdfbox.util.PDFTextStripper.processPage(PDFTextStripper.java:448)
	at org.apache.pdfbox.util.PDFTextStripperByArea.extractRegions(PDFTextStripperByArea.java:153)
	at br.com.pol.util.ProcessamentoPagina.run(ProcessamentoPagina.java:58)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

And the Exception:
2012-08-17 11:06:24 WARN  org.apache.pdfbox.pdfparser.BaseParser     - Corrupt object reference
java.lang.RuntimeException: java.io.IOException: Unknown dir object c=')' cInt=41 peek=')' peekInt=41 16400
	at org.apache.pdfbox.pdfparser.PDFStreamParser$1.tryNext(PDFStreamParser.java:187)
	at org.apache.pdfbox.pdfparser.PDFStreamParser$1.hasNext(PDFStreamParser.java:194)
	at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:257)
	at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:237)
	at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:217)
	at org.apache.pdfbox.util.PDFTextStripper.processPage(PDFTextStripper.java:448)
	at org.apache.pdfbox.util.PDFTextStripperByArea.extractRegions(PDFTextStripperByArea.java:153)

I´m sure it´s the multi thread access, because if I do not use thread, it work perfectly.

My code:
RandomAccess scratchFile = new RandomAccessFile(new File("tmp_"+source), "rw");
PDDocument document = PDDocument.loadNonSeq(new File(source), scratchFile);

Separate the pages at 5 threads, run each one at the Executor Service.

Thanks in advance.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira