You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Brendan Jurd <di...@gmail.com> on 2013/01/11 05:39:08 UTC
Failure to render text
Hi there,
I am trying to use pdfbox 1.7.1 to render PDFs in my application, with
mixed success. PDFs that consist of a single image for each page
(such as faxed TIFFs that have been converted to PDF) render quite
well, but PDFs containing text do not.
I've attached a copy of a CUPS printer test page. Viewed in Adobe
Reader, the document renders just fine. In my application, using
pdfbox's convertToImage, none of the text is rendered, nor the CUPS
logo. The only thing visibly rendered is the black border. Otherwise
the page is blank white.
pdfbox doesn't throw or log any exceptions. I've attached all the
DEBUG output generated in PDFStreamEngine while the page is failing to
render.
The test page was generated as postscript by CUPS, and then converted
to PDF by the ps2pdf utility.
I've tried to work around this using other libraries. pdfrenderer
manages to render the CUPS test page just fine, but completely bombs
out trying to render TIFFs. ICEpdf pro renders both types, but the
free version fails on text.
Is there a way I can make this work with pdfbox? Or, is there some
disciplined way to determine at runtime when pdfbox is failing to
render, so I can switch over to a different rendering library as
needed?
Cheers,
BJ
Re: Failure to render text
Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,
Am 14.01.2013 12:21, schrieb Brendan Jurd:
> On 14 January 2013 18:26, Andreas Lehmkuehler <an...@lehmi.de> wrote:
>> OK, it seems to be your environment. Let me guess you are using OpenJDK7,
>> aren't you?
>
> Partially correct. OpenJDK yes, but 6 rather than 7.
>
>> I'm experiencing some issues with fonts after installing fedora
>> 17
>> which comes with an OpneJDK7. I've switched to the "official" oracle jdk7
>> and
>> everything works as expected.
>
> Right. That might explain why I could see the text on Windows -- that
> machine was on sun-jdk and both Gentoo and Ubuntu were on openjdk.
> Any leads on how the choice of VM is affecting fonts in pdfbox? Is
> there a workaround?
Not that I know
> As I mentioned in the OP, the PDFRenderer library does manage to
> render the text with openjdk (and it copes with embedded TTF subsets
> too). Unfortunately it isn't isn't suitable for my project because it
> doesn't handle group 4 TIFFs, and the developers seem to have lost
> interest in the project. Would it be useful/practical to look at how
> they have handled fonts, and do something similar?
PDFBox relies on the JDK when it comes to render fonts and there are several
issue to do so. Subsets of TTFs aren't wellformed according to the TTF spec
and are rejected by the JDK font loader. Additionally there are some other
limitations/bugs in the loader which lead to the more or less poor results.
Good news is we are working on a JDK independent solution. The idea is to
extract the glyph information to render the font. But it is not that easy
and still takes some time, see [1] for further details.
BTW: AFAIK other PDF libraries are using a similar implementation.
> Cheers,
> BJ
>
BR
Andreas Lehmkühler
[1] https://issues.apache.org/jira/browse/PDFBOX-490
Re: Failure to render text
Posted by Brendan Jurd <di...@gmail.com>.
On 14 January 2013 18:26, Andreas Lehmkuehler <an...@lehmi.de> wrote:
> OK, it seems to be your environment. Let me guess you are using OpenJDK7,
> aren't you?
Partially correct. OpenJDK yes, but 6 rather than 7.
> I'm experiencing some issues with fonts after installing fedora
> 17
> which comes with an OpneJDK7. I've switched to the "official" oracle jdk7
> and
> everything works as expected.
Right. That might explain why I could see the text on Windows -- that
machine was on sun-jdk and both Gentoo and Ubuntu were on openjdk.
Any leads on how the choice of VM is affecting fonts in pdfbox? Is
there a workaround?
As I mentioned in the OP, the PDFRenderer library does manage to
render the text with openjdk (and it copes with embedded TTF subsets
too). Unfortunately it isn't isn't suitable for my project because it
doesn't handle group 4 TIFFs, and the developers seem to have lost
interest in the project. Would it be useful/practical to look at how
they have handled fonts, and do something similar?
Cheers,
BJ
Re: Failure to render text
Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,
Am 13.01.2013 22:58, schrieb Brendan Jurd:
> On 11 January 2013 17:44, Andreas Lehmkuehler <an...@lehmi.de> wrote:
>> First of all, please subscribe yourself to the mailing list [1] otherwise
>> you won't get any answers in the future. Your're getting this one solely
>> because I cc'ed you manually.
>>
>
> I have done so.
+1 :-)
>> Your attachments didn't make it due to some restrictions to the mailing
>> list. But as moderator I had access and I ran some tests ...
>
> Okay. What is your preferred way for me to make files available to the list?
An URL for a download or attach it to a JIRA [1] ticket when reporting a bug
>> Hmmm, it works fine for me using 1.7.1. Did you ever try to use the
>> PDFReader provided by PDFBox. If it works maybe something with your code is
>> wrong.
>
> I just tried that. PDFReader renders the black border, and the CUPS
> logo graphic, but none of the text. I used File -> Save as Image to
> export the failed render. You can view it at [1], and the original
> PDF is at [2].
>
> So, if it is working for you and not for me, I figure that the problem
> has something to do with my operating environment. This is Gentoo
> Linux x86_64 with KDE. I tried it on Windows Server 2008 64-bit, and
> it worked fine there. I then tried it on Ubuntu with GNOME and got
> the same result as Gentoo/KDE. Any ideas what could cause the same
> pdfbox JAR to render text on some systems but not others? Is it
> having trouble acquiring fonts, perhaps?
OK, it seems to be your environment. Let me guess you are using OpenJDK7,
aren't you? I'm experiencing some issues with fonts after installing fedora 17
which comes with an OpneJDK7. I've switched to the "official" oracle jdk7 and
everything works as expected.
> Cheers,
> BJ
>
> [1] https://docs.google.com/file/d/0B1-kBA9pHgNYLWpoVnRVanhpVnM/edit
> [2] https://docs.google.com/file/d/0B1-kBA9pHgNYQXJMZUxYTE5RaXM/edit
BR
Andreas Lehmkühler
[1] https://issues.apache.org/jira/browse/PDFBOX
Re: Failure to render text
Posted by Brendan Jurd <di...@gmail.com>.
On 11 January 2013 17:44, Andreas Lehmkuehler <an...@lehmi.de> wrote:
> First of all, please subscribe yourself to the mailing list [1] otherwise
> you won't get any answers in the future. Your're getting this one solely
> because I cc'ed you manually.
>
I have done so.
> Your attachments didn't make it due to some restrictions to the mailing
> list. But as moderator I had access and I ran some tests ...
Okay. What is your preferred way for me to make files available to the list?
> Hmmm, it works fine for me using 1.7.1. Did you ever try to use the
> PDFReader provided by PDFBox. If it works maybe something with your code is
> wrong.
I just tried that. PDFReader renders the black border, and the CUPS
logo graphic, but none of the text. I used File -> Save as Image to
export the failed render. You can view it at [1], and the original
PDF is at [2].
So, if it is working for you and not for me, I figure that the problem
has something to do with my operating environment. This is Gentoo
Linux x86_64 with KDE. I tried it on Windows Server 2008 64-bit, and
it worked fine there. I then tried it on Ubuntu with GNOME and got
the same result as Gentoo/KDE. Any ideas what could cause the same
pdfbox JAR to render text on some systems but not others? Is it
having trouble acquiring fonts, perhaps?
Cheers,
BJ
[1] https://docs.google.com/file/d/0B1-kBA9pHgNYLWpoVnRVanhpVnM/edit
[2] https://docs.google.com/file/d/0B1-kBA9pHgNYQXJMZUxYTE5RaXM/edit
Re: Failure to render text
Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,
Am 11.01.2013 05:39, schrieb Brendan Jurd:
> Hi there,
First of all, please subscribe yourself to the mailing list [1] otherwise you
won't get any answers in the future. Your're getting this one solely because I
cc'ed you manually.
> I am trying to use pdfbox 1.7.1 to render PDFs in my application, with
> mixed success. PDFs that consist of a single image for each page
> (such as faxed TIFFs that have been converted to PDF) render quite
> well, but PDFs containing text do not.
>
> I've attached a copy of a CUPS printer test page. Viewed in Adobe
> Reader, the document renders just fine. In my application, using
> pdfbox's convertToImage, none of the text is rendered, nor the CUPS
> logo. The only thing visibly rendered is the black border. Otherwise
> the page is blank white.
Your attachments didn't make it due to some restrictions to the mailing list.
But as moderator I had access and I ran some tests ...
> pdfbox doesn't throw or log any exceptions. I've attached all the
> DEBUG output generated in PDFStreamEngine while the page is failing to
> render.
>
> The test page was generated as postscript by CUPS, and then converted
> to PDF by the ps2pdf utility.
>
> I've tried to work around this using other libraries. pdfrenderer
> manages to render the CUPS test page just fine, but completely bombs
> out trying to render TIFFs. ICEpdf pro renders both types, but the
> free version fails on text.
>
> Is there a way I can make this work with pdfbox? Or, is there some
> disciplined way to determine at runtime when pdfbox is failing to
> render, so I can switch over to a different rendering library as
> needed?
Hmmm, it works fine for me using 1.7.1. Did you ever try to use the PDFReader
provided by PDFBox. If it works maybe something with your code is wrong.
> Cheers,
> BJ
>
BR
Andreas Lehmkühler
[1] http://pdfbox.apache.org/mail-lists.html