Answer the question
In order to leave comments, you need to log in
How to make iText handle Cyrillic?
How to make iTextPdf write Cyrillic to pdf file?
PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(file));
document.open();
BaseFont baseFont = BaseFont.createFont("src/Components/font/cyr.ttf", BaseFont.CP1250, BaseFont.EMBEDDED);
Font font = new Font(baseFont, 14, Font.NORMAL);
document.add(new com.itextpdf.text.Paragraph(text, font));
Answer the question
In order to leave comments, you need to log in
Font font = FontFactory.getFont("/fonts/DejaVuSans.ttf", "cp1251", BaseFont.EMBEDDED, 10);
try (FileOutputStream fs = new FileOutputStream(file)) {
Document document = new Document();
PdfWriter.getInstance(document, fs);
document.open();
Paragraph paragraph = new Paragraph();
paragraph.add(new Paragraph("Привет", normalFont));
document.add(paragraph);
document.close();
}
catch (DocumentException exc) {}
catch (IOException exc) {}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question