PDFBOX : U+000A ('controlLF') is not available in this font Helvetica encoding: WinAnsiEncoding

razvan picture razvan · Oct 9, 2017 · Viewed 12.5k times · Source

When trying to print a PDF page using Java and the org.apache.pdfbox library, I get this error:

PDFBOX : U+000A ('controlLF') is not available in this font Helvetica encoding: WinAnsiEncoding

Answer

razvan picture razvan · Oct 9, 2017

[PROBLEM] The String you are trying to display contains a newline character.

[SOLUTION] Replace the String with a new one and remove the newline:

text = text.replace("\n", "").replace("\r", "");