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

Cannot encode strings with of surrogate pairs

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.8
    • Fix Version/s: 2.0.9, 3.0.0 PDFBox
    • Component/s: FontBox
    • Labels:

      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

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

              Dates

              • Created:
                Updated:
                Resolved: