How to get iText to process the Cyrillic alphabet?

How to make iTextPdf to write in a pdf file the Cyrillic alphabet?
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));

Used a lot of ways, none works
June 27th 19 at 15:24
1 answer
June 27th 19 at 15:26
Solution
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("Hello", normalFont));
document.add(paragraph);
document.close();
}
catch (DocumentException exc) {}
catch (IOException exc) {}

Just don't forget to add in resources font and compile the program specifying the encoding of the source code.
finally happened, so many fonts used, none came, it came. Thank you - Shana_Hal commented on June 27th 19 at 15:29

Find more questions by tags Java