Hi,

> Am 19.08.2015 um 14:23 schrieb Taiarol, Felipe <[email protected]>:
> 
> 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.


You have to use PDFBox 2.0.0 if you're not already doing so. In addition you 
need to use a font which has these characters and load it

PDFont font = PDType0Font.load(doc, new File(path to you ttf file));

Please take a look at the HelloWorldTTF example in the examples project.

BR
Maruan

> 
> 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
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]

Reply via email to