0

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.

M. Yousfi
  • 578
  • 5
  • 24
  • 1
    due to the complexity of rendering Tamil language (mainly due to ligatures), the add-on [pdfCalligraph](https://itextpdf.com/products/itext-7/pdfcalligraph) is required for proper rendering. – André Lemos Jun 15 '23 at 13:00

0 Answers0