I would like to create a Pdf file in the android. I use "itextpdf" and create pdf file but after putting Persian text, does not show me anything. below you could find a source which I used https://medium.com/android-school/exploring-itext-to-create-pdf-in-android-5577881998c8 Although I change the font, still have the problem.
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(fileName));
document.open();
document.setPageSize(PageSize.A4);
document.addCreationDate();
document.addAuthor("Sample");
document.addCreator("Sample");
BaseColor mColorAccent = new BaseColor(0, 153, 204, 255);
float mHeadingFontSize = 20.0f;
float mValueFontSize = 26.0f;
BaseFont urName = BaseFont.createFont("assets/fonts/brandon_bold.otf", "UTF-8", BaseFont.EMBEDDED);
LineSeparator lineSeparator = new LineSeparator();
lineSeparator.setLineColor(new BaseColor(0, 0, 0, 68));
// Title Order Details...
// Adding Title....
Font mOrderDetailsTitleFont = new Font(urName, 36.0f, Font.NORMAL, BaseColor.BLACK);
Chunk mOrderDetailsTitleChunk = new Chunk("تست", mOrderDetailsTitleFont);
Paragraph mOrderDetailsTitleParagraph = new Paragraph(mOrderDetailsTitleChunk);
mOrderDetailsTitleParagraph.setAlignment(Element.ALIGN_CENTER);
document.add(mOrderDetailsTitleParagraph);
// Fields of Order Details...
// Adding Chunks for Title and value
Font mOrderIdFont = new Font(urName, mHeadingFontSize, Font.NORMAL, mColorAccent);
Chunk mOrderIdChunk = new Chunk("Order No:", mOrderIdFont);
Paragraph mOrderIdParagraph = new Paragraph(mOrderIdChunk);
document.add(mOrderIdParagraph);
Font mOrderIdValueFont = new Font(urName, mValueFontSize, Font.NORMAL, BaseColor.BLACK);
Chunk mOrderIdValueChunk = new Chunk("#123123", mOrderIdValueFont);
Paragraph mOrderIdValueParagraph = new Paragraph(mOrderIdValueChunk);
document.add(mOrderIdValueParagraph);
// Adding Line Breakable Space....
document.add(new Paragraph(""));
// Adding Horizontal Line...
document.add(new Chunk(lineSeparator));
// Adding Line Breakable Space....
document.add(new Paragraph(""));
// Fields of Order Details...
Font mOrderDateFont = new Font(urName, mHeadingFontSize, Font.NORMAL, mColorAccent);
Chunk mOrderDateChunk = new Chunk("Order Date:", mOrderDateFont);
Paragraph mOrderDateParagraph = new Paragraph(mOrderDateChunk);
document.add(mOrderDateParagraph);
Font mOrderDateValueFont = new Font(urName, mValueFontSize, Font.NORMAL, BaseColor.BLACK);
Chunk mOrderDateValueChunk = new Chunk("06/07/2017", mOrderDateValueFont);
Paragraph mOrderDateValueParagraph = new Paragraph(mOrderDateValueChunk);
document.add(mOrderDateValueParagraph);
document.add(new Paragraph(""));
document.add(new Chunk(lineSeparator));
document.add(new Paragraph(""));
// Fields of Order Details...
Font mOrderAcNameFont = new Font(urName, mHeadingFontSize, Font.NORMAL, mColorAccent);
Chunk mOrderAcNameChunk = new Chunk("Account Name:", mOrderAcNameFont);
Paragraph mOrderAcNameParagraph = new Paragraph(mOrderAcNameChunk);
document.add(mOrderAcNameParagraph);
Font mOrderAcNameValueFont = new Font(urName, mValueFontSize, Font.NORMAL, BaseColor.BLACK);
Chunk mOrderAcNameValueChunk = new Chunk("Pratik Butani", mOrderAcNameValueFont);
Paragraph mOrderAcNameValueParagraph = new Paragraph(mOrderAcNameValueChunk);
document.add(mOrderAcNameValueParagraph);
document.add(new Paragraph(""));
document.add(new Chunk(lineSeparator));
document.add(new Paragraph(""));
document.close();