You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Clark, Raymond C" <Ra...@ehi.com> on 2017/01/20 20:39:51 UTC

Why this warning out of PDFBox?

Hi,

Sometimes I am getting the following error:
[log4j][ServiceQueueSyncProcessThread: '2' for queue ProductsStmtService][2017-01-19 20:42:21,675] org.apache.pdfbox.pdmodel.font.PDCIDFontType2 WARN  Using fallback font LiberationSans for CID-keyed TrueType font ArialMT

In my code I am always setting the PDFont object to Arial:
       PDDocument document = new PDDocument();
       File fontFile = new File(getClass().getClassLoader().getResource("Fonts/arial.ttf").toURI());
       PDFont font = PDType0Font.load(document, fontFile);

My code generates a PDF every time it gets a request.  Sometimes I get this message and sometimes I don't and all of the time I am using the Arial font.  When I do get this message it seems to appear every time that I am calling to put text on that PDF.  Then the next request may not have this message while processing.

Any ideas as to why this message is coming out?
Any ideas as to why it would only come out sometimes?

As you can see I have the font file loaded.

Thank you,
Ray

________________________________

CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.



Re: Why this warning out of PDFBox?

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 20.01.2017 um 21:39 schrieb Clark, Raymond C:
> Hi,
>
> Sometimes I am getting the following error:
> [log4j][ServiceQueueSyncProcessThread: '2' for queue ProductsStmtService][2017-01-19 20:42:21,675] org.apache.pdfbox.pdmodel.font.PDCIDFontType2 WARN  Using fallback font LiberationSans for CID-keyed TrueType font ArialMT
>
> In my code I am always setting the PDFont object to Arial:
>         PDDocument document = new PDDocument();
>         File fontFile = new File(getClass().getClassLoader().getResource("Fonts/arial.ttf").toURI());
>         PDFont font = PDType0Font.load(document, fontFile);
>
> My code generates a PDF every time it gets a request.  Sometimes I get this message and sometimes I don't and all of the time I am using the Arial font.  When I do get this message it seems to appear every time that I am calling to put text on that PDF.  Then the next request may not have this message while processing.
>
> Any ideas as to why this message is coming out?
> Any ideas as to why it would only come out sometimes?

It means that it can't find the ArialMT font (or a similar one, e.g. 
Helvetica) on your system fonts, so it uses the last resort which is 
LiberationSans. I don't know why you get it sometimes and sometimes not.

I'm also wondering why you would get it related to a PDType0Font.load() 
call.

As I said before, the best would be
- update to the latest version so that we can be sure that the problem 
still happens
- solve the other problems you mentioned
- create a scenario where this happens regularly, preferably without tomcat
- share that code

If you can't do that, then build from source and modify 
PDCIDFontType2.java like this:

-LOG.warn("Using fallback font " + ttfFont.getName() + " for CID-keyed 
TrueType font " + getBaseFont());
+LOG.warn(new Exception(), "Using fallback font " + ttfFont.getName() + 
" for CID-keyed TrueType font " + getBaseFont());


Btw you can also use PDType1Font.HEVETICA, unless embedding is important 
for you, e.g. because you create a PDF/A file.

Tilman



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