Khmer Unicode support in iText

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Khmer Unicode support in iText

leejava
Dear all,

Now I want to display Khmer Unicode in iText and the range of Khmer Unicode from 1780 to 17FF.
I can display Khmer Unicode in iText by using these code as below:

public class UnicodeExamplePDF {

    public static void main(String[] args) {
        Document document = new Document();

        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("UnicodeExamplePDF.pdf"));
            document.open();

            BaseFont bfComic = BaseFont.createFont("D:/Kh Content.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            document.add(new Paragraph("Unicode: បង្រៀនភាសារខ្មែរទៅកាន់ពិភពបច្ចេកវិទ្យា......", new Font(bfComic, 12)));
            ColumnText columnText = new ColumnText(writer.getDirectContent());
            columnText.setRunDirection(PdfWriter.RUN_DIRECTION_LTR);
            columnText.addElement(new Paragraph("Unicode: បង្រៀនភាសារខ្មែរទៅកាន់ពិភពបច្ចេកវិទ្យា......", new Font(bfComic, 12)));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        document.close();
    }
}

And I got incorrect display as what I have expected.


and here is and expected result

Reply | Threaded
Open this post in threaded view
|

Re: Khmer Unicode support in iText

Balder VC
I don't really see a difference between the correct and incorrect one,
(except for the background color) but that might be due to me not being
able to read Khmer.

But you should write the \uXXXX notation for the characters instead of
writing the 'special char'

On 09/15/2011 10:58 AM, leejava wrote:

> Dear all,
>
> Now I want to display Khmer Unicode in iText and the range of Khmer Unicode
> from 1780 to 17FF.
> I can display Khmer Unicode in iText by using these code as below:
>
> public class UnicodeExamplePDF {
>
>     public static void main(String[] args) {
>         Document document = new Document();
>
>         try {
>             PdfWriter writer = PdfWriter.getInstance(document, new
> FileOutputStream("UnicodeExamplePDF.pdf"));
>             document.open();
>
>             BaseFont bfComic = BaseFont.createFont("D:/Kh Content.ttf",
> BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
>             document.add(new Paragraph("Unicode:
> បង្រៀនភាសារខ្មែរទៅកាន់ពិភពបច្ចេកវិទ្យា......", new Font(bfComic, 12)));
>             ColumnText columnText = new
> ColumnText(writer.getDirectContent());
>             columnText.setRunDirection(PdfWriter.RUN_DIRECTION_LTR);
>             columnText.addElement(new Paragraph("Unicode:
> បង្រៀនភាសារខ្មែរទៅកាន់ពិភពបច្ចេកវិទ្យា......", new Font(bfComic, 12)));
>         } catch (Exception e) {
>             System.err.println(e.getMessage());
>         }
>         document.close();
>     }
> }
>
> And I got incorrect display as what I have expected.
> http://itext-general.2136553.n4.nabble.com/file/n3815030/incorrect.png 
>
> and here is and expected result
> http://itext-general.2136553.n4.nabble.com/file/n3815030/correct.png 
>
>
> --
> View this message in context: http://itext-general.2136553.n4.nabble.com/Khmer-Unicode-support-in-iText-tp3815030p3815030.html
> Sent from the iText - General mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Doing More with Less: The Next Generation Virtual Desktop
> What are the key obstacles that have prevented many mid-market businesses
> from deploying virtual desktops?   How do next-generation virtual desktops
> provide companies an easier-to-deploy, easier-to-manage and more affordable
> virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
> _______________________________________________
> iText-questions mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php

--
Balder VC
http://www.redlab.be/blog/
http://twitter.com/redlabbe

------------------------------------------------------------------------------
Doing More with Less: The Next Generation Virtual Desktop
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops?   How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Reply | Threaded
Open this post in threaded view
|

Re: Khmer Unicode support in iText

leejava
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Khmer Unicode support in iText

leejava
The problem is that iText doesn't display the under script correctly.
Here is the example for comparing the correct display and incorrect display in iText for Khmer Unicode.



And here the code to test this issue.

public class UnicodeExamplePDF {

    public static void main(String[] args) {
        Document document = new Document();

        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("UnicodeExamplePDF.pdf"));
            document.open();

            BaseFont bfComic = BaseFont.createFont("D:/Kh Content.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            document.add(new Paragraph("\u1781\u17d2\u1789\u17bb\u17c6", new Font(bfComic, 12)));
           
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        document.close();
    }
}

Could you kindly advise how to fix it in iText?

Best regards,
LeeJava
Reply | Threaded
Open this post in threaded view
|

Re: Khmer Unicode support in iText

iText mailing list
On 16/09/2011 4:22, leejava wrote:
> The problem is that iText doesn't display the under script correctly.

So what you are saying is that you have two bytes, each corresponding
with a glyph in your font. iText is displaying these two SEPARATE bytes
correctly, but that's not your intention. You want the two SEPARATE
bytes to be combined into one DIFFERENT glyph. In correct terminology,
you want to iText to support LIGATURES in Khmer.

iText supports ligatures in Arabic, but not in Indic languages and not
in Khmer. As you can imagine, none of our developers understand Khmer
(or Hindi for that matter), so we depend on somebody who knows those
languages to write that code for us. If you would be so kind to donate
that code to the iText project, we would be very happy to integrate it
into one of the next releases.

------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Reply | Threaded
Open this post in threaded view
|

Re: Khmer Unicode support in iText

leejava
ok, so could you explain me how to develop it in iText?
I will try to pay my time to do it, because I want Khmer Unicode display correctly in iText.
Please advise.

Reply | Threaded
Open this post in threaded view
|

Re: Khmer Unicode support in iText

iText mailing list
On 16/09/2011 9:12, leejava wrote:
> ok, so could you explain me how to develop it in iText?
> I will try to pay my time to do it, because I want Khmer Unicode display
> correctly in iText.
> Please advise.
Read the iText library developer guide:
http://www.redlab.be/blog/2011/developer-guide/
Look at the code that makes the ligatures for Arabic.
Create a KhmerLigaturization class and make it work the same way
ArabicLigaturization works.

------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php