Not able to convert Tamil fonts

150 Views Asked by At

I am using html2pdf from iTextPdf to convert a html file to pdf. I am using the latest version of iText. That is version 8.0.0 of itext7-core and version 5.0.0 of html2pdf. I am using NotoSansTamil-Regular font file. Here is my code.

// Initialize PDF writer
PdfWriter writer = new PdfWriter(pdfFilePath);

// Initialize PDF document
PdfDocument pdf = new PdfDocument(writer);

ConverterProperties props = new ConverterProperties();
FontProvider fp = new DefaultFontProvider(true, true,true );

fp.addFont("PATH_TO_MY_FONT_FILE");
props.setFontProvider(fp);

pdf.addEventHandler(PdfDocumentEvent.END_PAGE, new FooterHandler());
// Convert HTML to PDF
HtmlConverter.convertToPdf(new FileInputStream(htmlFilePath), pdf, props);

I am including UTF-8 in my Html Charset.

After the conversion, my Pdf has some letter swapped in the words and some help written. Can some please help me what may be wrong here ?

I tried changing the font files. Like ANSI and Unicode fonts. None of them worked. I even changed the font family of the CSS even that did not work.

0

There are 0 best solutions below