danfickle / openhtmltopdf

An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
https://danfickle.github.io/pdf-templates/index.html
Other
1.93k stars 359 forks source link

Tamil character using @font-face Noto-sans-tamil is not rendering properly #958

Open shengistired opened 11 months ago

shengistired commented 11 months ago

PDF:

image

ACTUAL DATA: ஆண் குழந்தை தமிழ் பெயர்கள்

When i tried the copy the tamil text from the pdf and paste it somewhere else, it looks the same as the actual data. I believe this is a similar issue to #925 .

Font: https://fonts.google.com/noto/specimen/Noto+Sans+Tamil

CSS:

@font-face {
     font-family: tamil;
     font-weight: 500;
     font-style: normal;
     src: url('../../fonts/NotoSansTamil-Light.ttf');
     -fs-pdf-font-embed: embed;
     -fs-pdf-font-encoding: Identity-H;
}

Java code:

builder.withHtmlContent(htmlContent, ""); // Provide base URI if needed
                builder.toStream(outputStream);
                builder.run();

try (FileOutputStream fileOutputStream = new FileOutputStream(path)) {
                    fileOutputStream.write(outputStream.toByteArray());
                }