[
https://issues.apache.org/jira/browse/PDFBOX-1389?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
John Hewson closed PDFBOX-1389.
-------------------------------
Resolution: Invalid
PDFBox is not thread safe, see the FAQ.
> 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
> Labels: noob
>
> 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 was sent by Atlassian JIRA
(v6.2#6252)