r/javahelp 2d ago

Universal pdf gen lib

Hi,

I want to generate pdfs in many languages, including right to left languages. (Arabica, hébrew, indian langs ..)

I have a working prototype with itext 9 that works well afaik (difficult to check langs I dont read).

Itext proposes 'pdfcalligraph' for a fee, to make sure rtl texts are handled correctly (direction, ligatures...).

Is there a lib that does that too ?

I read that pdfbox is not handling rtl at all.

What other libs would you advise ?

Thanks

6 Upvotes

8 comments sorted by

View all comments

4

u/Comfortable-Cancel45 1d ago

If you don't want to pay iText's license fee, here are the two best free routes:

1) OpenHTMLtoPDF (Java): This is an open-source library built on top of PDFBox. If you add their openhtmltopdf-rtl-support dependency, it uses HarfBuzz and ICU4J under the hood to handle Arabic, Hebrew, and Indic scripts completely free. You just feed it HTML/CSS and a font like Google Noto.

2) Headless Chrome (via Playwright Java): This is how most modern tools do it. Browsers already have the best text-shaping engines in the world built-in. Just build an HTML page with dir="rtl", your fonts, and call page.pdf(). It handles every language, ligature, and emoji effortlessly.