You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by Craig Stires <cr...@gmail.com> on 2011/03/24 22:35:48 UTC

pdmodel.font.PDSimpleFont hanging on TrueType font (ubuntu)

 

Hi,

 

First post to the pdfbox dev team.  So, first things first.  Thank you for
your efforts into this quality product.  Have been using PDFBox for a while
now, and it's held up to a lot of different documents that have needed
parsing and thumbnailing.

 

Onto the issue that I have come across.

 

When calling PDPage.convertToImage(imagetype,resolution) , I have found a
case where the application hangs.  No error messages, no exceptions, no CPU
spike, no I/O.  The error had to do with some strange corruption of the
awtFont, by the time it reached the method PDSimpleFont.drawString.  Some
pretty deep digging turned up that if a font with too few glyphs is sent
into PDSimpleFont.writeFont, it will enter Graphics2D.drawString ... ne'er
to return.

 

If a check is done to count the glyphs and if they fall below a certain
threshold, then just re-instantiate the Font, then all goes well.  Typical
numbers range from 70 to 1000+, so I've gone with an arbitrary value of 40.
All goes well, and I can't measure any difference in performance (except
that my app will actually return from attempting this doc!).

 

I've got a sample PDF which can re-create the problem, and a patch which
seems to solve it sensibly.

 

Who is maintaining this part of the project, for me to send to?

 

My configuration

O/S : Ubuntu 8.04 Headless

PDFBox : 1.5.0

 

The offending string

Font : Tahoma

String : 0x20  (space)

 

 

Thanks,

-Craig

 


Re: pdmodel.font.PDSimpleFont hanging on TrueType font (ubuntu)

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,

Am 24.03.2011 22:35, schrieb Craig Stires:
>
>
> Hi,
>
>
>
> First post to the pdfbox dev team.  So, first things first.  Thank you for
> your efforts into this quality product.  Have been using PDFBox for a while
> now, and it's held up to a lot of different documents that have needed
> parsing and thumbnailing.
>
>
>
> Onto the issue that I have come across.
>
>
>
> When calling PDPage.convertToImage(imagetype,resolution) , I have found a
> case where the application hangs.  No error messages, no exceptions, no CPU
> spike, no I/O.  The error had to do with some strange corruption of the
> awtFont, by the time it reached the method PDSimpleFont.drawString.  Some
> pretty deep digging turned up that if a font with too few glyphs is sent
> into PDSimpleFont.writeFont, it will enter Graphics2D.drawString ... ne'er
> to return.
>
>
>
> If a check is done to count the glyphs and if they fall below a certain
> threshold, then just re-instantiate the Font, then all goes well.  Typical
> numbers range from 70 to 1000+, so I've gone with an arbitrary value of 40.
> All goes well, and I can't measure any difference in performance (except
> that my app will actually return from attempting this doc!).
Sounds interesting ...


> I've got a sample PDF which can re-create the problem, and a patch which
> seems to solve it sensibly.
>
>
>
> Who is maintaining this part of the project, for me to send to?
We, the PDFBox community, are maintaining the project. Please create an isssue 
on JIRA and attach both the sample pdf and the patch to it. I'm sure that 
someone will take care of it.


> My configuration
>
> O/S : Ubuntu 8.04 Headless
>
> PDFBox : 1.5.0
>
>
>
> The offending string
>
> Font : Tahoma
>
> String : 0x20  (space)

Thanks in advance,
Andreas Lehmkühler


[1] https://issues.apache.org/jira/browse/PDFBOX