0

I am trying to create a pdf with the pdfbox library, and in the content I need the "ñ" character to go, however the resulting pdf only shows me strange characters

I tried the other encoding UTF8, windows 1252, etc. and with characters like "\ u00f1", but I still have the same problem

            content.beginText();
            content.setFont(PDType1Font.HELVETICA, 14);
            content.moveTextPositionByAmount(230, y);
            content.drawString("S/. 5,000 Mensuales por 20 a\u00f1os");
            content.endText();
  • Possible duplicate of [Using PDFBox to write UTF-8 encoded strings to a PDF](https://stackoverflow.com/questions/5425251/using-pdfbox-to-write-utf-8-encoded-strings-to-a-pdf) – second Sep 25 '19 at 16:16
  • Possible duplicate of [Apache PDFBox: Can I set font other than those present in PDType1Font](https://stackoverflow.com/questions/41313554/apache-pdfbox-can-i-set-font-other-than-those-present-in-pdtype1font) – Tilman Hausherr Sep 25 '19 at 16:57
  • it is not possible embed a font because the jar is executed from a linux server with java version 1.4 so the PDFBOX version is 0.7.3, which does not allow font embed – Miguel Angel Quevedo Sep 25 '19 at 18:53
  • Are you sure about that? At least the documentation for that version (obtained from [`here`](https://sourceforge.net/projects/pdfbox/files/PDFBox/)) has a small section for `Embedding TrueType Fonts`. – second Sep 25 '19 at 22:03
  • 1
    But even if you can use a custom font, you might have no luck, as this [`discussion`](https://stackoverflow.com/questions/1713751/using-java-pdfbox-library-to-write-russian-pdf) seems to indicate that versions a few years later still had no utf-8 support. – second Sep 25 '19 at 22:23
  • Yes, you need 2.0 for full flexibility. That one needs jdk 1.6. – Tilman Hausherr Sep 26 '19 at 07:52

0 Answers0