http://markmail.org/thread/r2bbln57hjng7bxu

Here is an example for a Bulgarian text that appear strange in the PDF :

// Create a new PDF & write some Bulgarian text in it using a Bulgarian font.
try {
 PDDocument pdfFile = new PDDocument();
 String filePath = "C:\\new_bulgarian.pdf";       
 
 PDTrueTypeFont font = PDTrueTypeFont.loadTTF( pdfFile, new 
File("fonts/bulgarian.ttf") );
 //font.setEncoding( new WinAnsiEncoding() );
 
 PDPage page = new PDPage();
 PDPageContentStream contentStream = new PDPageContentStream( pdfFile, page );
 
 contentStream.beginText();
 contentStream.setFont( font, 10 );
 contentStream.moveTextPositionByAmount( 50, 720 );
 contentStream.drawString( "??????? ????????" );  // Bulgarian Text.
 contentStream.moveTextPositionByAmount( 0, -12 );
 contentStream.endText();
 contentStream.close();
 
 pdfFile.addPage( page );
 pdfFile.save( filePath );
 pdfFile.close();
} catch (IOException e) {
 e.printStackTrace();
} catch (COSVisitorException e) {
 e.printStackTrace();
}

Thanks ,
Hesham

Reply via email to