-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support right-to-left (RTL) text and mixed direction text. #9
Comments
Implementation details:
PdfBoxRenderer renderer = new PdfBoxRenderer(false);
renderer.setBidiSplitter(new ICUBidiSplitter.ICUBidiSplitterFactory());
renderer.setDefaultTextDirection(false); // false for LTR, true for RTL.
renderer.setBidiReorderer(new ICUBidiReorderer()); |
You will also need an appropriate font for all right-to-left scripts. You can use one or more of the noto family of fonts from Google. For Arabic, your stylesheet might look like this: @font-face {
font-family: noto;
src: url(NotoNaskhArabic-Regular.ttf);
}
body, body * {
font-family: 'noto', sans-serif;
} |
OK, with the implementation of multiple font fallback for the PDF renderer - #10 - the RTL support can now be used for PDF output. |
👍 |
… RTL and BIDI implementation. [ci skip]
Implements the dir attribute and also the bdi element. Fixes several bugs in the original RTL implementation.
Hi, I got separated words for unicode even with the correct font, please check this pdf file @danfickle the sample source code is available here |
Hi @omidp <div class="arabic" style="font-size:30px;">
ديگر وب سايتهاي شركت كسب و كار نوين ايرانيان
</div> I'm no font expert but I think that all fonts don't contain the presentational forms that PDF requires as now on screen renderers can do the job themselves. In the sandbox, I'm using |
@danfickle after some straggling, I realized that it's a bug in Apache pdfbox. |
Hi @omidp I agree totally that better font support is essential, I'm just not sure if it works or not with fonts with the presentational forms built-in. Thanks, |
I confirm that showcase is correct even though I'm unable to reproduce it. sounds like Arabic text is working with the font you have mentioned earlier but Persian text is not working. some of Persian characters still fail to join. I'll get back for more comprehensive feedback ASAP. |
Push to anything but main will trigger a dev release, every push to main a proper GitHub release. Not sure if you've discussed the release process yet? Might be worth looking into [JReleaser](https://jreleaser.org/)
Support RTL text such as Arabic. I've divided this issue up into the following tasks. Note that Bidi and ArabicShaping classes come from ICU4J. The aim is to provide identical output to Chrome browser with dir="auto" set on html element. The implementation uses interfaces with a do nothing implementation by default to avoid a compulsory dependency on ICU4J.
The text was updated successfully, but these errors were encountered: