You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Mickael Marrache <mi...@gmail.com> on 2018/04/27 06:13:34 UTC

PDFBOX cache warning and embedded fonts

Hi,

After encountering the following error:

java.lang.IllegalArgumentException: U+05E5 ('afii57685') is not available
in this font Helvetica encoding: WinAnsiEncoding
at org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:426)
I'm embedding the font I want to use as follows:

PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();
PDResources res = acroForm.getDefaultResources();
PDType0Font font = PDType0Font.load(pdfDocument,
PDFBoxUtils.class.getClassLoader().getResourceAsStream("DAVID.TTF"));
COSName fontName = res.add(font);
acroForm.setDefaultResources(res);
textField.setDefaultAppearance("/" + fontName.getName() + " 0 Tf 0 g");

I expect the font to be embedded but then I see the following in the logs:

[org.apache.pdfbox.pdmodel.font.PDCIDFontType2] - Using fallback font
LiberationSans for CID-keyed TrueType font David

Before fixing fonts for text fields using the snippet above, the text
fields are set with the font David (via Acrobat DC). I can understand
PDFBOX can't find this font because it is not installed on the server.
However, the fonts are changed with an embedded font available on the
classpath so I don't understand why I get that warning.

I also thought the warnings are generated when the document is loaded
(before text fields are fixed) but then I tried to open the generated PDF
with Acrobat Reader and I see squares instead of valid characters.

I also precise I flatten the acroform.

Thanks,
Mickael

Re: PDFBOX cache warning and embedded fonts

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 27.04.2018 um 09:48 schrieb Mickael Marrache:
> Thanks Tilman, that solved the issue.
>
> However, I see the following INFO in the logs:
>
> [org.apache.pdfbox.pdmodel.font.PDCIDFontType2] - OpenType Layout tables
> used in font David are not implemented in PDFBox and will be ignored

Don't bother... it just means that we haven't implemented substitution 
(e.g. ligatures for ff, fl, fi, ffl) yet.

Tilman

>
> Could you please explain what it means?
>
> On Fri, Apr 27, 2018 at 10:28 AM, Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Am 27.04.2018 um 08:13 schrieb Mickael Marrache:
>>
>>> PDType0Font font = PDType0Font.load(pdfDocument,
>>> PDFBoxUtils.class.getClassLoader().getResourceAsStream("DAVID.TTF"));
>>>
>>
>> Try setting the third parameter to false.
>>
>>
>> Tilman
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: PDFBOX cache warning and embedded fonts

Posted by Mickael Marrache <mi...@gmail.com>.
Thanks Tilman, that solved the issue.

However, I see the following INFO in the logs:

[org.apache.pdfbox.pdmodel.font.PDCIDFontType2] - OpenType Layout tables
used in font David are not implemented in PDFBox and will be ignored

Could you please explain what it means?

On Fri, Apr 27, 2018 at 10:28 AM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Am 27.04.2018 um 08:13 schrieb Mickael Marrache:
>
>> PDType0Font font = PDType0Font.load(pdfDocument,
>> PDFBoxUtils.class.getClassLoader().getResourceAsStream("DAVID.TTF"));
>>
>
>
> Try setting the third parameter to false.
>
>
> Tilman
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: PDFBOX cache warning and embedded fonts

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 27.04.2018 um 08:13 schrieb Mickael Marrache:
> PDType0Font font = PDType0Font.load(pdfDocument,
> PDFBoxUtils.class.getClassLoader().getResourceAsStream("DAVID.TTF"));


Try setting the third parameter to false.


Tilman



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org