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

Incorrect embedding of non-subset fonts.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0, 2.0.2, 2.0.3, 3.0.0 PDFBox
    • 2.0.3, 3.0.0 PDFBox
    • PDModel
    • None

    Description

      The following code produces a broken PDF.

      final String DIR = "/Users/user/Documents/pdf/";
      PDDocument doc = new PDDocument();
      PDPage pg = new PDPage();
      PDPageContentStream con = new PDPageContentStream(doc, pg);
      con.beginText();
      // Working fine when below is true, not when it is false.
      con.setFont(PDType0Font.load(doc, new FileInputStream(DIR + "NotoSans-Regular.ttf"), false), 16);
      con.setTextMatrix(Matrix.getTranslateInstance(50, 600));
      con.showText("Hello World");
      con.endText();
      con.close();
      doc.addPage(pg);
      doc.save(new File(DIR + "out.pdf"));
      doc.close();
      

      As mentioned in the code, it works fine when the subset is true. I've tried it with a few fonts. The referenced font is downloadable from here:
      https://www.google.com/fonts#UsePlace:use/Collection:Noto+Sans

      Behavior in Chrome: Shows random characters.
      Behavior in Mac Preview: Shows selectable whitespace.
      Behavior in Acrobat Reader: Shows message on open (Cannot find or create the font 'NotoSans'. Some characters may not display or print correctly). Shows dots instead of characters.
      Behavior in Safari: Same as preview.

      Tested with 2.0.0 and 2.0.2.

      Why does this matter? We need a complete font to embed to use in text acro form fields.

      Thanks.

      Attachments

        Activity

          People

            tilman Tilman Hausherr
            danfickle Dan Fickling
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: