pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Taiarol, Felipe" <felipe.taia...@sap.com>
Subject How to Print UTF-8 Characters
Date Wed, 19 Aug 2015 12:23:14 GMT
Hi,

I am trying to create PDFs in languages such as Chinese and Russian but the characters of
those languages are not being printed correctly.

This code outputs the attached PDF.

I read it has something to do with PDF not supporting UTF-8, I tried to use a font which had
those characters but it didn’t work.


String text = "ру́сский язы́к, ру́сский язы́к, ру́сский
язы́к";

PDDocument document = new PDDocument();

PDPage page = new PDPage();

document.addPage(page);

PDFont font = PDType1Font.HELVETICA_BOLD;

PDPageContentStream contentStream = new PDPageContentStream( document, page);

contentStream.beginText();

contentStream.setFont(font, 12);

contentStream.moveTextPositionByAmount(100, 700);

contentStream.drawString(text);

contentStream.endText();

contentStream.close();

document.save("Hello World.pdf");

document.close();

Does PDFBox supports printing this type of characters ? How can this be done ?


Thanks in advance!


Felipe
Mime
View raw message