Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4115

Problem creating PDF with German text using embedded Type1 (PFB) font



      When creating a PDF and adding text using a PostScript Type1 font (e.g. the attached n019003l.pfb but also others), an error occurs when the text contains German characters.

      The error occurs with e.g. the character "ä" (adieresis) and other similar umlaut characters; it does not occur with "ß" (germandbls).

      Using an embedded TTF seems to work fine but when I load the PFB like this:

      InputStream pfb = new FileInputStream(fontFile);
      font = new PDType1Font(document, pfb);

      I get an encoding error whenever I try to print an "ä" to the page:

      java.lang.IllegalArgumentException: U+00E4 ('adieresis') is not available in this font NimbusSanL-Regu (generic: NimbusSanL-Regu) encoding: built-in (Type 1)

      If I specify a different encoding (WinANSI) when loading the font:

      InputStream pfb = new FileInputStream(fontFile);
      font = new PDType1Font(document, pfb, new WinAnsiEncoding());

      then the exception is not thrown, but I just have an empty space in place of the "ä".

      I have tried to look into the code, in particular I have played around with the class PDType1FontEmbedder.

      When the FontBox object Type1Font is created by the parser in the following line of code:

      type1 = Type1Font.createWithPFB(pfbBytes);

      I have tried to look into the charstring dictionary:


      and, by iterating through the set keys, can see that "adieresis" is in there.

      However, when using the default encoding from the font (i.e. by passing "null" to the PDType1FontEmbedder), the resulting encoding that is obtained by the following line of code:

      fontEncoding = Type1Encoding.fromFontBox(type1.getEncoding());

      does not contain "adieresis" (or other "compound" characters), but just "dieresis".


        1. n019003l.pfb
          77 kB
          Tamir Hassan



            • Assignee:
              tilman Tilman Hausherr
              tamirhassan Tamir Hassan
            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: