Hi Juho

This isn’t supported in 1.8 but the 2.0 trunk version supports embedding TTF 
fonts using Unicode.
Follow the instruction on our website for build from source or downloading a 
snapshot.

Once you have 2.0, follow this example:

https://github.com/apache/pdfbox/blob/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFonts.java

-- John

> On 9 Jan 2015, at 00:35, Juho Terrijärvi <[email protected]> 
> wrote:
> 
> Hey all,
> 
> I'm using pdfbox 1.8.8 and trying to write unicode or UTF-8 with Cyrillic 
> alphabets. The bookmarks work correct:
> 
> PDOutlineItem subHeading = new PDOutlineItem();
> subHeading.setTitle(allDocsToAddExp[i]);
> page = (PDPage)pages.get( num );
> dest = new PDPageFitWidthDestination();
> subHeading.setDestination( dest );
> dest.setPage( page );
> heading.appendChild( subHeading );
> 
> But when I write to the document with:
> 
> // append the content to the existing stream
> PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, 
> true, true);
> contentStream.beginText();
> // set font and font size
> contentStream.setFont( PDType1Font.TIMES_ROMAN, 10f );
> // set text color
> contentStream.setNonStrokingColor(0, 0, 0);
> if (rotate)
> {
> // rotate the text according to the page rotation
>            contentStream.setTextRotation(Math.PI/2, x, y);
> }
> else
> {
>            contentStream.setTextTranslation(x, y);
> }
> contentStream.drawString(message);
> contentStream.endText();
> contentStream.close();
> 
> This only produces þÿ
> ________________________________
> @
> ________________________________
> 0
> ________________________________
> 1
> ________________________________
>> 
> ________________________________
> B
> ________________________________
> 0
> 
> What could be the problem?
> 
> Best,
> 
> Juho
> 
> Ps. I find your work amazing! With pdfbox I can do the months work I did 
> before in a day. So pdfbox has made it possible for me to spend 19 days in a 
> month in more rational things.

Reply via email to