Issue with Thai Characters Rendering in PDF

80 views
Skip to first unread message

Sangeetha Pandian

unread,
Feb 9, 2024, 8:01:46 AM2/9/24
to Flying Saucer Users

Hi everyone,

I'm facing an issue with rendering Thai characters (specifically ที่, นั้, นั่) properly in PDF files. I have tried using various fonts such as Mai tree, Noto Serif, Chonburi and Sarabun, but unfortunately, I have not found a solution yet.

The characters appear distorted or incorrectly rendered in the generated PDF files. I have ensured that the fonts I am using support the Thai language, but the problem persists.

If anyone has encountered a similar issue or has any suggestions for resolving this problem, I would greatly appreciate your insights and assistance.

Thank you!

Sangeetha Pandian

unread,
Feb 9, 2024, 8:53:16 AM2/9/24
to Flying Saucer Users
Screenshot 2024-02-09 at 7.23.06 PM.png

Andrei Solntsev

unread,
Feb 9, 2024, 10:14:41 AM2/9/24
to flying-sa...@googlegroups.com
Hi Sangeetha!

It's impossible to say anything useful without seeing your code. 

Show the code: how exactly are you running FlyingSaucers? How are you adding the fonts?

P.S. Recently we already had a problem with CJK fonts, may be yours is similar?


Andrei Solntsev


пт, 9 февр. 2024 г. в 15:01, Sangeetha Pandian <sangeeth...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Flying Saucer Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flying-saucer-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flying-saucer-users/3a8f5d76-2e19-473b-a9ff-4e52ed75dbdcn%40googlegroups.com.

Sangeetha Pandian

unread,
Feb 9, 2024, 10:34:51 AM2/9/24
to flying-sa...@googlegroups.com
Thanks, 
I checked the issue that you faced and I already using Identity-H encoding
             
Here is the code

String htmlContent = "<html><body><h1>ที่ ,นั้ น, นั่ น</h1></body></html>";
OutputStream pdf = Files.newOutputStream(Paths.get("output/thai.pdf"))
ITextRenderer renderer = new ITextRenderer();
SharedContext sharedContext = renderer.getSharedContext();
String font = "/fonts/Maitree-Regular.ttf";
renderer.getFontResolver().addFont(font, BaseFont.IDENTITY_H, true);
renderer.setDocumentFromString(htmlContent);
renderer.layout();
renderer.createPDF(pdf);

You received this message because you are subscribed to a topic in the Google Groups "Flying Saucer Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/flying-saucer-users/BDgcwCxiFOw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to flying-saucer-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flying-saucer-users/CAE7WSaF7tvMnrq4pFawO%3DWoR5ZcYk2qgnh0hxbEiTpohyCzV3Q%40mail.gmail.com.

Peter Brant

unread,
Feb 9, 2024, 5:55:45 PM2/9/24
to flying-sa...@googlegroups.com
I don't know if this applies to Thai specifically, but support for fonts (languages) that use mandatory ligatures, combining characters, etc. is basically non-existent.

Reply all
Reply to author
Forward
0 new messages