You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Kirk, Kenneth" <Kk...@ILSOS.NET> on 2015/06/04 21:20:03 UTC
PDFRederer PdfBox-2.0
I have a client application that convert pdf documents into single page tiff images. Since the user export large quantities of documents I use a multithreaded approach. Each thread loads it own document and converts the pages one by one.
The pdf file is serialized to the client thread and then each thread executes the following code. If I only use 1 thread there is no problem. I checked to make sure objects are shared between threads.
docin = PDDocument.load(new ByteArrayInputStream(documentResult.getImage().getContent()),true);
if(null==docin)
throw new Exception("Invalid PDF document or an occured during retrieval");
int numPages = docin.getNumberOfPages();
String strPath = getPath(numPages);
int iPage = 0;
PDFRenderer renderer = new PDFRenderer(docin);
for (int i=0;i<numPages;i++)
{
PDPage page = docin.getPage(i);
PDRectangle rect = page.getMediaBox();
BufferedImage pageImage = null;
pageImage = renderer.renderImageWithDPI(i, 200f, ImageType.BINARY);
...
}
Array index out of range: 8
at org.apache.fontbox.ttf.GlyfSimpleDescript.readFlags(GlyfSimpleDescript.java:202)
at org.apache.fontbox.ttf.GlyfSimpleDescript.<init>(GlyfSimpleDescript.java:77)
at org.apache.fontbox.ttf.GlyphData.initData(GlyphData.java:58)
at org.apache.fontbox.ttf.GlyphTable.getGlyph(GlyphTable.java:161)
at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForGID(TTFGlyph2D.java:140)
at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForCharacterCode(TTFGlyph2D.java:92)
at org.apache.pdfbox.rendering.PageDrawer.drawGlyph2D(PageDrawer.java:333)
at org.apache.pdfbox.rendering.PageDrawer.showFontGlyph(PageDrawer.java:314)
at org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:731)
at org.apache.pdfbox.contentstream.PDFStreamEngine.showText(PDFStreamEngine.java:690)
at org.apache.pdfbox.rendering.PageDrawer.showText(PageDrawer.java:296)
at org.apache.pdfbox.contentstream.PDFStreamEngine.showTextStrings(PDFStreamEngine.java:600)
at org.apache.pdfbox.contentstream.operator.text.ShowTextAdjusted.process(ShowTextAdjusted.java:38)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:802)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:464)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:438)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:179)
at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:205)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:136)
at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:95)
at org.ilsos.cm.export.client.rmi.workers.Pdf2SinglePageTiff.processResult(Pdf2SinglePageTiff.java:142)
at org.ilsos.cm.export.client.rmi.ExportWorker.run(ExportWorker.java:72)
at java.lang.Thread.run(Thread.java:784)
************************************************
Disclaimer - This email and any files transmitted with it are confidential and contain privileged or copyright information. You must not present this message to another party without gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify the Office of the Illinois Secretary of State.
If you have received this message in error, please notify the sender immediately, and delete this email from your system. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Office of the Illinois Secretary of State.
************************************************
Re: PDFRederer PdfBox-2.0
Posted by Tilman Hausherr <TH...@t-online.de>.
Kenneth -
in TrueTypeFont.java, search for the line
public GeneralPath getPath(String name) throws IOException
and replace it with
public synchronized GeneralPath getPath(String name) throws IOException
Or set yourself as a watcher in this issue:
https://issues.apache.org/jira/browse/PDFBOX-2824
Tilman
Am 04.06.2015 um 21:20 schrieb Kirk, Kenneth:
> I have a client application that convert pdf documents into single page tiff images. Since the user export large quantities of documents I use a multithreaded approach. Each thread loads it own document and converts the pages one by one.
> The pdf file is serialized to the client thread and then each thread executes the following code. If I only use 1 thread there is no problem. I checked to make sure objects are shared between threads.
>
> docin = PDDocument.load(new ByteArrayInputStream(documentResult.getImage().getContent()),true);
> if(null==docin)
> throw new Exception("Invalid PDF document or an occured during retrieval");
> int numPages = docin.getNumberOfPages();
> String strPath = getPath(numPages);
> int iPage = 0;
> PDFRenderer renderer = new PDFRenderer(docin);
> for (int i=0;i<numPages;i++)
> {
> PDPage page = docin.getPage(i);
> PDRectangle rect = page.getMediaBox();
> BufferedImage pageImage = null;
> pageImage = renderer.renderImageWithDPI(i, 200f, ImageType.BINARY);
> ...
> }
>
> Array index out of range: 8
> at org.apache.fontbox.ttf.GlyfSimpleDescript.readFlags(GlyfSimpleDescript.java:202)
> at org.apache.fontbox.ttf.GlyfSimpleDescript.<init>(GlyfSimpleDescript.java:77)
> at org.apache.fontbox.ttf.GlyphData.initData(GlyphData.java:58)
> at org.apache.fontbox.ttf.GlyphTable.getGlyph(GlyphTable.java:161)
> at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForGID(TTFGlyph2D.java:140)
> at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForCharacterCode(TTFGlyph2D.java:92)
> at org.apache.pdfbox.rendering.PageDrawer.drawGlyph2D(PageDrawer.java:333)
> at org.apache.pdfbox.rendering.PageDrawer.showFontGlyph(PageDrawer.java:314)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:731)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.showText(PDFStreamEngine.java:690)
> at org.apache.pdfbox.rendering.PageDrawer.showText(PageDrawer.java:296)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.showTextStrings(PDFStreamEngine.java:600)
> at org.apache.pdfbox.contentstream.operator.text.ShowTextAdjusted.process(ShowTextAdjusted.java:38)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:802)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:464)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:438)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
> at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:179)
> at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:205)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:136)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:95)
> at org.ilsos.cm.export.client.rmi.workers.Pdf2SinglePageTiff.processResult(Pdf2SinglePageTiff.java:142)
> at org.ilsos.cm.export.client.rmi.ExportWorker.run(ExportWorker.java:72)
> at java.lang.Thread.run(Thread.java:784)
>
>
>
>
>
>
>
>
>
> ************************************************
> Disclaimer - This email and any files transmitted with it are confidential and contain privileged or copyright information. You must not present this message to another party without gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify the Office of the Illinois Secretary of State.
>
> If you have received this message in error, please notify the sender immediately, and delete this email from your system. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Office of the Illinois Secretary of State.
> ************************************************
>
>
>
>
>
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
RE: PDFRederer PdfBox-2.0
Posted by "Kirk, Kenneth" <Kk...@ILSOS.NET>.
I placed a synchronization block around the renderImageWithDPI method and the problem goes away but since this method can take some time to complete it slows the whole process down. This problem happens right away and just after the so many documents. I will try with a different set of documents as I think the ones I am working were created using IText.
-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de]
Sent: Thursday, June 04, 2015 2:33 PM
To: users@pdfbox.apache.org
Subject: Re: PDFRederer PdfBox-2.0
I have opened https://issues.apache.org/jira/browse/PDFBOX-2824 .
Amusingly / tragically, I have the same problem and I'm a committer here. I did try setting "synchronized" at a few suspicious places, but it didn't help. My problem is that the error happens only about every 50 build. Can you provoke the error with one or several non confidential files? That would be helpful.
Tilman
Am 04.06.2015 um 21:20 schrieb Kirk, Kenneth:
> I have a client application that convert pdf documents into single page tiff images. Since the user export large quantities of documents I use a multithreaded approach. Each thread loads it own document and converts the pages one by one.
> The pdf file is serialized to the client thread and then each thread executes the following code. If I only use 1 thread there is no problem. I checked to make sure objects are shared between threads.
>
> docin = PDDocument.load(new ByteArrayInputStream(documentResult.getImage().getContent()),true);
> if(null==docin)
> throw new Exception("Invalid PDF document or an occured during retrieval");
> int numPages = docin.getNumberOfPages();
> String strPath = getPath(numPages);
> int iPage = 0;
> PDFRenderer renderer = new PDFRenderer(docin);
> for (int i=0;i<numPages;i++)
> {
> PDPage page = docin.getPage(i);
> PDRectangle rect = page.getMediaBox();
> BufferedImage pageImage = null;
> pageImage = renderer.renderImageWithDPI(i, 200f, ImageType.BINARY);
> ...
> }
>
> Array index out of range: 8
> at org.apache.fontbox.ttf.GlyfSimpleDescript.readFlags(GlyfSimpleDescript.java:202)
> at org.apache.fontbox.ttf.GlyfSimpleDescript.<init>(GlyfSimpleDescript.java:77)
> at org.apache.fontbox.ttf.GlyphData.initData(GlyphData.java:58)
> at org.apache.fontbox.ttf.GlyphTable.getGlyph(GlyphTable.java:161)
> at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForGID(TTFGlyph2D.java:140)
> at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForCharacterCode(TTFGlyph2D.java:92)
> at org.apache.pdfbox.rendering.PageDrawer.drawGlyph2D(PageDrawer.java:333)
> at org.apache.pdfbox.rendering.PageDrawer.showFontGlyph(PageDrawer.java:314)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:731)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.showText(PDFStreamEngine.java:690)
> at org.apache.pdfbox.rendering.PageDrawer.showText(PageDrawer.java:296)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.showTextStrings(PDFStreamEngine.java:600)
> at org.apache.pdfbox.contentstream.operator.text.ShowTextAdjusted.process(ShowTextAdjusted.java:38)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:802)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:464)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:438)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
> at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:179)
> at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:205)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:136)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:95)
> at org.ilsos.cm.export.client.rmi.workers.Pdf2SinglePageTiff.processResult(Pdf2SinglePageTiff.java:142)
> at org.ilsos.cm.export.client.rmi.ExportWorker.run(ExportWorker.java:72)
> at java.lang.Thread.run(Thread.java:784)
>
>
>
>
>
>
>
>
>
> ************************************************
> Disclaimer - This email and any files transmitted with it are confidential and contain privileged or copyright information. You must not present this message to another party without gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify the Office of the Illinois Secretary of State.
>
> If you have received this message in error, please notify the sender immediately, and delete this email from your system. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Office of the Illinois Secretary of State.
> ************************************************
>
>
>
>
>
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
************************************************
Disclaimer - This email and any files transmitted with it are confidential and contain privileged or copyright information. You must not present this message to another party without gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify the Office of the Illinois Secretary of State.
If you have received this message in error, please notify the sender immediately, and delete this email from your system. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Office of the Illinois Secretary of State.
************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDFRederer PdfBox-2.0
Posted by Tilman Hausherr <TH...@t-online.de>.
I have opened https://issues.apache.org/jira/browse/PDFBOX-2824 .
Amusingly / tragically, I have the same problem and I'm a committer
here. I did try setting "synchronized" at a few suspicious places, but
it didn't help. My problem is that the error happens only about every 50
build. Can you provoke the error with one or several non confidential
files? That would be helpful.
Tilman
Am 04.06.2015 um 21:20 schrieb Kirk, Kenneth:
> I have a client application that convert pdf documents into single page tiff images. Since the user export large quantities of documents I use a multithreaded approach. Each thread loads it own document and converts the pages one by one.
> The pdf file is serialized to the client thread and then each thread executes the following code. If I only use 1 thread there is no problem. I checked to make sure objects are shared between threads.
>
> docin = PDDocument.load(new ByteArrayInputStream(documentResult.getImage().getContent()),true);
> if(null==docin)
> throw new Exception("Invalid PDF document or an occured during retrieval");
> int numPages = docin.getNumberOfPages();
> String strPath = getPath(numPages);
> int iPage = 0;
> PDFRenderer renderer = new PDFRenderer(docin);
> for (int i=0;i<numPages;i++)
> {
> PDPage page = docin.getPage(i);
> PDRectangle rect = page.getMediaBox();
> BufferedImage pageImage = null;
> pageImage = renderer.renderImageWithDPI(i, 200f, ImageType.BINARY);
> ...
> }
>
> Array index out of range: 8
> at org.apache.fontbox.ttf.GlyfSimpleDescript.readFlags(GlyfSimpleDescript.java:202)
> at org.apache.fontbox.ttf.GlyfSimpleDescript.<init>(GlyfSimpleDescript.java:77)
> at org.apache.fontbox.ttf.GlyphData.initData(GlyphData.java:58)
> at org.apache.fontbox.ttf.GlyphTable.getGlyph(GlyphTable.java:161)
> at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForGID(TTFGlyph2D.java:140)
> at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForCharacterCode(TTFGlyph2D.java:92)
> at org.apache.pdfbox.rendering.PageDrawer.drawGlyph2D(PageDrawer.java:333)
> at org.apache.pdfbox.rendering.PageDrawer.showFontGlyph(PageDrawer.java:314)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:731)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.showText(PDFStreamEngine.java:690)
> at org.apache.pdfbox.rendering.PageDrawer.showText(PageDrawer.java:296)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.showTextStrings(PDFStreamEngine.java:600)
> at org.apache.pdfbox.contentstream.operator.text.ShowTextAdjusted.process(ShowTextAdjusted.java:38)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:802)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:464)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:438)
> at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
> at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:179)
> at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:205)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:136)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:95)
> at org.ilsos.cm.export.client.rmi.workers.Pdf2SinglePageTiff.processResult(Pdf2SinglePageTiff.java:142)
> at org.ilsos.cm.export.client.rmi.ExportWorker.run(ExportWorker.java:72)
> at java.lang.Thread.run(Thread.java:784)
>
>
>
>
>
>
>
>
>
> ************************************************
> Disclaimer - This email and any files transmitted with it are confidential and contain privileged or copyright information. You must not present this message to another party without gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify the Office of the Illinois Secretary of State.
>
> If you have received this message in error, please notify the sender immediately, and delete this email from your system. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Office of the Illinois Secretary of State.
> ************************************************
>
>
>
>
>
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org