I am using iText PDF to create PDF files in android. I need to write the '₹' symbol in the PDF. I have the following code:-
public static final String FONT1 = "/main/assets//PlayfairDisplay-Regular.ttf";
public static final String FONT2 = "/main/assets/PT_Sans-Web-Regular.ttf";
public static final String FONT3 = "/main/assets/FreeSans.ttf";
public static final String RUPEE = "The Rupee character \u20B9 and the Rupee symbol \u20A8";
These are declared as class variables. I have a function createPDF() which writes to the PDF document. I have the following lines of code in the function:-
File pdfFile = new File(filePath);
OutputStream output = new FileOutputStream(pdfFile);
Document document = new Document(PageSize.A4);
PdfWriter.getInstance(document, output);
document.open();
Font f1 = FontFactory.getFont(FONT1, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12);
Font f2 = FontFactory.getFont(FONT2, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12);
Font f3 = FontFactory.getFont(FONT3, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12);
Font f4 = FontFactory.getFont(FONT3, BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
document.add(new Paragraph(RUPEE, f1));
document.add(new Paragraph(RUPEE, f2));
document.add(new Paragraph(RUPEE, f3));
document.add(new Paragraph(RUPEE, f4));
document.close();
However neither the font gets reflected in the PDF nor the Rupee Symbol. My PDF looks as below:-
I have followed steps using the below links:- iText Developers Tutorial and StackOverflow Question on where to place Assets folder
I am aware of another similar question on SO:- Rupee symbol is not showing in android however this also has not helped me.
Am I doing anything wrong here ? Are my fonts placed in the wrong location?