I just implement to put the render of Khmer Unicode in iText 5.5.4-SNAPSHOT and try, I could produce the PDF with the right display as following image.
iText is a core pdf writer in most of the opensource library for outputting report or rendering text but unfortunately, it’s not working with Khmer Unicode as I stated previously in my post.
It’s just only the initial work and not yet done and sure that it’s fully working fine yet.
Remark: I have read: http://www.redlab.be/blog/2011/developer-guide/
And I have tried:
itext/src/main/java/com/itextpdf/text/pdf/TrueTypeFont.java itext/src/main/java/com/itextpdf/text/pdf/languages/khmer itext/src/main/java/com/itextpdf/text/pdf/languages/khmer/UnicodeRender.java itext/src/main/java/com/itextpdf/text/pdf/languages/khmer/UnicodeUtil.java itext/src/main/java/com/itextpdf/text/pdf/languages/KhmerLigaturizer.java
Update:
There won’t be an easy task to integrate the latest iText (5.x) version to some opensource product such as JasperReport to test Khmer render since they are still using very old version 2.1.7.
One more remark on iText product about its revolution since version 2.1.7, 4.2.0 to 5.x:
Source Code
- Sample Project with the Jar: https://github.com/osify/iTextKhmerSample (you can take the iText jar for that purpose, I do not have enough time to manage full source of the modification yet)
30 replies on “iText can render for Khmer Unicode”
A good start for me.
Its working fine but if there is any symbol which position is bottom of a letter(conjunct letter) doesn’t show.In that case it shows only a plus(+) sign bottom of that letter.Your attached image is a good example which has a plus symbol (2nd line, last character).How to resolve it? Thanks.
I can’t see it working. I have tried it with IText 5.5.6 but it does not work. Is this supported by iText now?
I have modified itext in my local dev. I will package for testing. Current itext no Khmer support
Currently iText 7 has support for Khmer.
Thank you, this is what i am looking for.
Sample code added
If I wanted to make a modified iText build (5.5.9-SNAPSHOT) that has Khmer support, how exactly would I integrate this code? It’s not entirely clear to me how you made it work.
@amedee, I haven’t sent the pull request to add that into itext yet, but I have extended the itext latest version to add the modification, you can see: https://github.com/Seuksa/iTextKhmer
Currently a bit confusing on license of itext and stuck me.
@osify, When i try to print “Hello World សួស្តីពិភពលោក”(from Google translate) to PDF the the Hello World will be missing and the vowel below of first and second character seems to be right adjusted and the vowel below of second character become a cross.
@vlcheong, are you using or following this sample: https://github.com/Seuksa/iTextKhmerSample ? I will check if the combination of Khmer & English can work together on that render or not or we might need to use different font for that.
for your reference http://postimg.org/image/m8o3f6ye5/. Thanks
@osify, thanks for your prompt reply. I’ve pushed my test to my github, you may check it out at https://github.com/vlcheong/itext-khmer. You need Java 7 to run the test, just type “mvn test” 1 pdf file will be output at the basedir.
My bad, I didn’t commit my last modify of my sample, please have a look again, I just committed. The jar used here: https://github.com/Seuksa/iTextKhmerSample/tree/master/lib
Just tested the jar file still the same 🙁
Please see, my sample, to write:
KhmerLigaturizer d = new KhmerLigaturizer();
String strProcess = d.process(“ហេតុនេះយើងត្រូវតែរួមគ្នាដោះស្រាយ ខ្លួន ស្វាគមន៍មកកាន់អូស៊ីហ្វាយ”);
BaseFont bfComic = BaseFont.createFont(localFontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
document.add(new Paragraph(“Hello”));
document.add(new Paragraph(strProcess, new Font(bfComic, 22)));
So, the English and Khmer words can’t print as one string ? Actually, I read the source from a utf-8 encoded file. How about the lower vowel become a + like this http://postimg.org/image/m8o3f6ye5/ ? any idea how to fix it ?
Hi again, you just didn’t read my previous comment and explain in my sample project.
I took your test class and add it to my sample: https://github.com/Seuksa/iTextKhmerSample/blob/master/src/test/java/org/seuksa/sample/khmeriText/KhemerFontTest.java
Here is the result: https://github.com/Seuksa/iTextKhmerSample/blob/master/khemer.pdf
Thanks to use it and find the way to help contribute back for our country.
Hi osify, if i input the string like “កាលបរិចេ្ឆទ/Date”, the Date will disappear in the pdf. can u help?
Hi Osify, if កាលបរិចេ្ឆទ/Date, but Date will disappeared, any comments?
Yes, I acknowledge that, there is an issue with rendering for both English/Khmer characters. I have no solution yet.
@osify, Thanks for your helpful support. It looks like I forgot to process the string before print. Actually, I’m helping my client who invested in Cambodia to print some PDF document in Khmer.
@osify , Can Khmer be supported in Jasper reports , because from your posts on the discussions it seems the issue is with the iText jar , so is there any possble way that I can use khmer in Jasper , if yes , please guide me for the same and thanks in advance the blogs are really helpful .
Hi Vishal, from Jasper 6, it supported Khmer (http://ask.osify.com/qa/868)
Hi Brother Osify,
Thank for your effort to make itext support khmer unicode but it’s .jar … can you make it to .dll I would like to add to Visual Studio 2017
iText is for Java. What are you using for reports in VS 2017? Crystal report or Microsoft report?
I did long time ago for Crystal report, see at: http://osify.com/2008/12/khmer-unicode-with-crystal-report-in-c-application/#.XK2TnqJS-60
There is a version of iText for Java *AND* for .NET. See https://itextpdf.com/en/products/itext-7/itext-7-core
Or i confused. I use iTextSharp to create PDF but the problem is iTextSharp version 5 does not support khmer unicode under script.
Do you have solution for .Net C# with iTextsharp to show khmer unicode correctly.
If not, i see iText7 support khmer language , does it fully support? Have you ever tried ?
I have tested and also now used in production for some of my product too.
[…] Oudam on iText can render for Khmer Unicode […]