iText can render for Khmer Unicode
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)
This solution has been deemed correct by the post author
A good start for me.
Was this answer helpful?
LikeDislikeIts 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.
Was this answer helpful?
LikeDislikeI 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?
Was this answer helpful?
LikeDislikeI have modified itext in my local dev. I will package for testing. Current itext no Khmer support
Was this answer helpful?
LikeDislikeThank you, this is what i am looking for.
Sample code added
Was this answer helpful?
LikeDislikeIf 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.
Was this answer helpful?
LikeDislike@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.
Was this answer helpful?
LikeDislike@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.
Was this answer helpful?
LikeDislike@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.
Was this answer helpful?
LikeDislikefor your reference http://postimg.org/image/m8o3f6ye5/. Thanks
Was this answer helpful?
LikeDislike@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.
Was this answer helpful?
LikeDislikeMy 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
Was this answer helpful?
LikeDislikeJust tested the jar file still the same 🙁
Was this answer helpful?
LikeDislikePlease 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)));
Was this answer helpful?
LikeDislikeSo, 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 ?
Was this answer helpful?
LikeDislikeHi 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.
Was this answer helpful?
LikeDislikeHi osify, if i input the string like “កាលបរិចេ្ឆទ/Date”, the Date will disappear in the pdf. can u help?
Was this answer helpful?
LikeDislikeHi Osify, if កាលបរិចេ្ឆទ/Date, but Date will disappeared, any comments?
Was this answer helpful?
LikeDislikeYes, I acknowledge that, there is an issue with rendering for both English/Khmer characters. I have no solution yet.
Was this answer helpful?
LikeDislike@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.
Was this answer helpful?
LikeDislike@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 .
Was this answer helpful?
LikeDislikeHi Vishal, from Jasper 6, it supported Khmer (http://ask.osify.com/qa/868)
Was this answer helpful?
LikeDislike