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

Exception when trying to write Spanish or French characters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.0.0
    • None
    • Writing
    • None
    • Windows 10, Java 8

    Description

      When I create a PDF with PDFBOX 2.0.0 SNAPSHOT using the typical Hello World example with Spanish and French characters:

          PDDocument document = new PDDocument();
          PDPage page = new PDPage(PDRectangle.A4);
          document.addPage(page);
          PDType1Font font = PDType1Font.HELVETICA;
      
          PDPageContentStream stream = new PDPageContentStream(document, page);
          String text = "áÁÀà";
          stream.beginText();
          stream.setFont(font, 12);
          stream.newLineAtOffset(100, 700);
          stream.showText(text);
          stream.endText();
          stream.close();
          document.save("sample.pdf");
          document.close();
      

      I get this error:

      sep 02, 2015 12:42:43 PM org.apache.pdfbox.pdmodel.font.PDType1Font <init>
      ADVERTENCIA: Using fallback font ArialMT for base font ZapfDingbats
      Exception in thread "main" java.lang.IllegalArgumentException: This font type only supports 8-bit code points
      

      If I load arialuni.ttf font with Type0 it compiles but only get question marks instead of the correct characters in the PDF file.

      I have tried PDFBOX 1.8 and doesn´t work either.

      Attachments

        Activity

          People

            Unassigned Unassigned
            loonger Ivan de la Fuente
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: