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

Cannot encode strings with of surrogate pairs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.8
    • 2.0.9, 3.0.0 PDFBox
    • FontBox

    Description

      This code doesn't work:

      try (PDDocument doc = new PDDocument())
      {
          PDPage page = new PDPage();
          doc.addPage(page);
          try (PDPageContentStream cs = new PDPageContentStream(doc, page))
          {
              PDFont font = PDType0Font.load(doc, new File("NotoEmoji-Regular.ttf"));
              cs.setFont(font, 50);
              cs.beginText();
              cs.newLineAtOffset(100, 700);
              cs.showText("\uD83D\uDE81");
              cs.endText();
          }
          doc.save("heli.pdf");
      }
      

      It throws an exception

      IllegalArgumentException: No glyph for U+1F681 in font NotoEmoji

      Attachments

        1. heli.pdf
          3 kB
          Tilman Hausherr
        2. NotoEmoji-Regular.ttf
          409 kB
          Tilman Hausherr

        Activity

          People

            tilman Tilman Hausherr
            tilman Tilman Hausherr
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: