Discussion:
[iText-questions] Problem with Setting Arabic characters with Arial Unicode MS Font type
Harsha Kaundinya
2012-07-26 15:53:00 UTC
Permalink
HI,

I am facing a problem while assigning Arial MS Unicode Font to Arabic
Characters. Once the PDF is generated all the Arabic words are in
TimesNewRoman Font. If there are any other english numbers or characters
along with the Arabic characters, then they are set to Arial MS Unicode
Font. Why are Arabic Characters are not setting to Arial MS Unicode Font?

I am actually adding a paragraph to a PdfPCell and setting the run
direction to RTL in case of Arabic and Hebrew. Arabic fonts are differing
while its getting printed on to the iText PDF.

Is there someone who can help me on this???

Thank you.
Harsha
Paulo Soares
2012-07-26 17:21:51 UTC
Permalink
That's the way it works with the code you are using.

Paulo

On Thu, Jul 26, 2012 at 4:53 PM, Harsha Kaundinya <***@gmail.com> wrote:
> HI,
>
> I am facing a problem while assigning Arial MS Unicode Font to Arabic
> Characters. Once the PDF is generated all the Arabic words are in
> TimesNewRoman Font. If there are any other english numbers or characters
> along with the Arabic characters, then they are set to Arial MS Unicode
> Font. Why are Arabic Characters are not setting to Arial MS Unicode Font?
>
> I am actually adding a paragraph to a PdfPCell and setting the run direction
> to RTL in case of Arabic and Hebrew. Arabic fonts are differing while its
> getting printed on to the iText PDF.
>
> Is there someone who can help me on this???
>
> Thank you.
> Harsha
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> iText-questions mailing list
> iText-***@lists.sourceforge.net
> 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
Harsha Kaundinya
2012-07-27 02:30:33 UTC
Permalink
Then how can i achieve converting arabic characters to arial unicode MS
font? Because i am setting one font for the entire string and only english
characters are setting to Arial Unicode MS while arabic are being set to
times new roman font.

Harsha

On Thu, Jul 26, 2012 at 10:51 PM, Paulo Soares <***@gmail.com> wrote:

> That's the way it works with the code you are using.
>
> Paulo
>
> On Thu, Jul 26, 2012 at 4:53 PM, Harsha Kaundinya <***@gmail.com>
> wrote:
> > HI,
> >
> > I am facing a problem while assigning Arial MS Unicode Font to Arabic
> > Characters. Once the PDF is generated all the Arabic words are in
> > TimesNewRoman Font. If there are any other english numbers or characters
> > along with the Arabic characters, then they are set to Arial MS Unicode
> > Font. Why are Arabic Characters are not setting to Arial MS Unicode Font?
> >
> > I am actually adding a paragraph to a PdfPCell and setting the run
> direction
> > to RTL in case of Arabic and Hebrew. Arabic fonts are differing while its
> > getting printed on to the iText PDF.
> >
> > Is there someone who can help me on this???
> >
> > Thank you.
> > Harsha
> >
> ------------------------------------------------------------------------------
> > Live Security Virtual Conference
> > Exclusive live event will cover all the ways today's security and
> > threat landscape has changed and how IT managers can respond. Discussions
> > will include endpoint security, mobile security and the latest in malware
> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > _______________________________________________
> > iText-questions mailing list
> > iText-***@lists.sourceforge.net
> > 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
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> iText-questions mailing list
> iText-***@lists.sourceforge.net
> 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
>
Paulo Soares
2012-07-27 08:52:45 UTC
Permalink
How the hell do I know what's going on? Did you show us your code? Are
we all psychic to guess what you are doing?

iText does what it's told to do. You are doing something wrong but
didn't bother to tell us about your code.

Paulo

On Fri, Jul 27, 2012 at 3:30 AM, Harsha Kaundinya <***@gmail.com> wrote:
> Then how can i achieve converting arabic characters to arial unicode MS
> font? Because i am setting one font for the entire string and only english
> characters are setting to Arial Unicode MS while arabic are being set to
> times new roman font.
>
> Harsha
>
>
> On Thu, Jul 26, 2012 at 10:51 PM, Paulo Soares <***@gmail.com> wrote:
>>
>> That's the way it works with the code you are using.
>>
>> Paulo
>>
>> On Thu, Jul 26, 2012 at 4:53 PM, Harsha Kaundinya <***@gmail.com>
>> wrote:
>> > HI,
>> >
>> > I am facing a problem while assigning Arial MS Unicode Font to Arabic
>> > Characters. Once the PDF is generated all the Arabic words are in
>> > TimesNewRoman Font. If there are any other english numbers or characters
>> > along with the Arabic characters, then they are set to Arial MS Unicode
>> > Font. Why are Arabic Characters are not setting to Arial MS Unicode
>> > Font?
>> >
>> > I am actually adding a paragraph to a PdfPCell and setting the run
>> > direction
>> > to RTL in case of Arabic and Hebrew. Arabic fonts are differing while
>> > its
>> > getting printed on to the iText PDF.
>> >
>> > Is there someone who can help me on this???
>> >
>> > Thank you.
>> > Harsha
Harsha Kaundinya
2012-07-27 10:32:08 UTC
Permalink
The logic used to set the code to Arial Unicode MS is there below -

str is an arabic string that comes from a database.

BaseFont bfArialUni =
BaseFont.createFont("C:\\Windows\\Fonts" + "\\ARIALUNI.TTF",
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED);
Font fontArialUni = new Font(bfArialUni,12f);
Phrase myPhrase = new Phrase(str,fontArialUni);

PdfPTable table = new PdfPTable(1);
PdfPCell cell = new PdfPCell(new Paragraph(myPhrase));
cell.setColspan(3);
cell.setPaddingRight(15f);
cell.setBorder(PdfPCell.NO_BORDER);
cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);

table.addCell(cell);
document.add(table);

This code is not setting the arabic characters to arial unicode MS font.

On Fri, Jul 27, 2012 at 2:22 PM, Paulo Soares <***@gmail.com> wrote:

> How the hell do I know what's going on? Did you show us your code? Are
> we all psychic to guess what you are doing?
>
> iText does what it's told to do. You are doing something wrong but
> didn't bother to tell us about your code.
>
> Paulo
>
> On Fri, Jul 27, 2012 at 3:30 AM, Harsha Kaundinya <***@gmail.com>
> wrote:
> > Then how can i achieve converting arabic characters to arial unicode MS
> > font? Because i am setting one font for the entire string and only
> english
> > characters are setting to Arial Unicode MS while arabic are being set to
> > times new roman font.
> >
> > Harsha
> >
> >
> > On Thu, Jul 26, 2012 at 10:51 PM, Paulo Soares <***@gmail.com>
> wrote:
> >>
> >> That's the way it works with the code you are using.
> >>
> >> Paulo
> >>
> >> On Thu, Jul 26, 2012 at 4:53 PM, Harsha Kaundinya <***@gmail.com>
> >> wrote:
> >> > HI,
> >> >
> >> > I am facing a problem while assigning Arial MS Unicode Font to Arabic
> >> > Characters. Once the PDF is generated all the Arabic words are in
> >> > TimesNewRoman Font. If there are any other english numbers or
> characters
> >> > along with the Arabic characters, then they are set to Arial MS
> Unicode
> >> > Font. Why are Arabic Characters are not setting to Arial MS Unicode
> >> > Font?
> >> >
> >> > I am actually adding a paragraph to a PdfPCell and setting the run
> >> > direction
> >> > to RTL in case of Arabic and Hebrew. Arabic fonts are differing while
> >> > its
> >> > getting printed on to the iText PDF.
> >> >
> >> > Is there someone who can help me on this???
> >> >
> >> > Thank you.
> >> > Harsha
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> iText-questions mailing list
> iText-***@lists.sourceforge.net
> 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
>
iText Info
2012-07-27 10:40:14 UTC
Permalink
Op 27/07/2012 12:32, Harsha Kaundinya schreef:
> The logic used to set the code to Arial Unicode MS is there below -
>
> str is an arabic string that comes from a database.

Replace str with "\u0644\u0648\u0631\u0627\u0646\u0633
\u0627\u0644\u0639\u0631\u0628".
What happens? If the text says "Lawrence of Arabia" in correct Arabic,
then it's not an iText problem. It's something you're doing wrong, for
instance: you're extracting the String from the database using the wrong
encoding.
Harsha Kaundinya
2012-07-27 10:52:06 UTC
Permalink
I get an arabic output like áæÑÇäÓÇáÚÑÈ

This is not "Lawrence of Arabia". Its some "To Uransarab". I do not know
arabic. So i used Google Translate to check whats the actual Arabic
Translation. And it said "To Uransarab".

Harsha

On Fri, Jul 27, 2012 at 4:10 PM, iText Info <***@1t3xt.info> wrote:

> Op 27/07/2012 12:32, Harsha Kaundinya schreef:
> > The logic used to set the code to Arial Unicode MS is there below -
> >
> > str is an arabic string that comes from a database.
>
> Replace str with "\u0644\u0648\u0631\u0627\u0646\u0633
> \u0627\u0644\u0639\u0631\u0628".
> What happens? If the text says "Lawrence of Arabia" in correct Arabic,
> then it's not an iText problem. It's something you're doing wrong, for
> instance: you're extracting the String from the database using the wrong
> encoding.
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> iText-questions mailing list
> iText-***@lists.sourceforge.net
> 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
>
Alekz !
2012-07-27 14:26:56 UTC
Permalink
I don't know arabic, and don't know what google translate does in the guts either, but to me "To Uransarab" is close to "Lawrence of Arabia".I think it's not a literal translation, but a phonetic aproximation. See: To Uransarab -> Lo Urans arab -> LoWrans Arab -> Lawrence Arab -> Lawrence [of] Arabia The end point is, I think the problem is not in iText, since you got the arabic printed, right? Regards,Alex from Argentina (no pun intended)

Date: Fri, 27 Jul 2012 16:22:06 +0530
From: ***@gmail.com
To: itext-***@lists.sourceforge.net
Subject: Re: [iText-questions] Problem with Setting Arabic characters with Arial Unicode MS Font type

I get an arabic output like äèÑÇæÓÇäÙÑÈ

This is not "Lawrence of Arabia". Its some "To Uransarab". I do not know arabic. So i used Google Translate to check whats the actual Arabic Translation. And it said "To Uransarab".


Harsha

On Fri, Jul 27, 2012 at 4:10 PM, iText Info <***@1t3xt.info> wrote:

Op 27/07/2012 12:32, Harsha Kaundinya schreef:

> The logic used to set the code to Arial Unicode MS is there below -

>

> str is an arabic string that comes from a database.



Replace str with "\u0644\u0648\u0631\u0627\u0646\u0633

\u0627\u0644\u0639\u0631\u0628".

What happens? If the text says "Lawrence of Arabia" in correct Arabic,

then it's not an iText problem. It's something you're doing wrong, for

instance: you're extracting the String from the database using the wrong

encoding.



------------------------------------------------------------------------------

Live Security Virtual Conference

Exclusive live event will cover all the ways today's security and

threat landscape has changed and how IT managers can respond. Discussions

will include endpoint security, mobile security and the latest in malware

threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________

iText-questions mailing list

iText-***@lists.sourceforge.net

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




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
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
1T3XT BVBA
2012-07-27 15:52:58 UTC
Permalink
On 27/07/2012 16:26, Alekz ! wrote:
> I don't know arabic, and don't know what google translate does in the
> guts either, but to me "To Uransarab" is close to "Lawrence of Arabia".
> I think it's not a literal translation, but a phonetic aproximation. See:
>
> To Uransarab -> Lo Urans arab -> LoWrans Arab -> Lawrence Arab ->
> Lawrence [of] Arabia

I assumed that the original poster knew Arabic, and that he'd know that
Lawrence can't really be translated, it's more or less written
phonetically as you describe.

> The end point is, I think the problem is not in iText, since you got
> the arabic printed, right?

Indeed. I'm 99% sure that it's an encoding problem that occurs at the
moment String str is created or before that. For instance: wrong
encoding of the database, wrong assumptions of the encoding of the
database, creation of the str value using the wrong encoding,...

> Regards,
> Alex from Argentina (no pun intended)
;-)
1T3XT BVBA
2012-07-27 15:49:22 UTC
Permalink
On 27/07/2012 12:52, Harsha Kaundinya wrote:
> I get an arabic output like لورانسالعرب

That output is correct, it corresponds with the final line in this image:
http://www.flickr.com/photos/itextinaction/4330327604
Or with the final line in this PDF:
http://examples.itextpdf.com/results/part3/chapter11/ligatures_2.pdf
iText Info
2012-07-27 10:27:46 UTC
Permalink
Op 27/07/2012 4:30, Harsha Kaundinya schreef:
> Then how can i achieve converting arabic characters to arial unicode
> MS font?
If you have Arabic text in a digital document (flat text? database
field? HTML?), there's a 99% chance that the glyphs you see are
expressing in unicode characters. If you have unicode characters,
there's no need to 'convert' them.

Of course, there's plenty of things you can do wrong:
- wrong database encoding,
- wrong encoding used by the compiler,
- wrong encoding when reading a file,
- wrong encoding when defining the font object,
- ...
The list is almost endless, and as Paulo says: we can't help you if you
don't help us help you.

Maybe you can start by reading the book.
Continue reading on narkive:
Search results for '[iText-questions] Problem with Setting Arabic characters with Arial Unicode MS Font type' (Questions and Answers)
14
replies
Creating a "Why we should switch to Mac" Speech. Help Please?
started 2007-10-26 15:44:14 UTC
desktops
Loading...