wood burning stoves*
The moose likes Java in General and the fly likes How to write single byte and double byte characters on pdf using java api(iText) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to write single byte and double byte characters on pdf using java api(iText)" Watch "How to write single byte and double byte characters on pdf using java api(iText)" New topic
Author

How to write single byte and double byte characters on pdf using java api(iText)

Ramasamy Anbalagan
Greenhorn

Joined: Dec 14, 2009
Posts: 20
Can anyone help me on my below requirement,

Requirement
---------------
We want to write all European and Asian languages characters on pdf document.

The problem is i can able to write European language characters alone on pdf, similarly i can write Asian language characters as well. but the problem is i am not able to write Asian and European languages together.

Can anyone suggest/point me what should we do for writing those language characters together on pdf document.

Thanks...
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Why aren't you able to do so?


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Ramasamy Anbalagan
Greenhorn

Joined: Dec 14, 2009
Posts: 20
Thanks for have look on my post...

i can write all Europian language characters with the default font, but i can not write Asian characters with the default font.

if i want to write Asian characters, i need to set below fonts(for chinese) for working fine.


Language : Chinese (Simplified)
Fonts : STSong-Light
CMap names : UniGB-UCS2-H

If i set those font some of the Europian language not able to write....

point me if done anythign wrong...

Thanks...



Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Ramasamy Anbalagan wrote:Thanks for have look on my post...

i can write all Europian language characters with the default font, but i can not write Asian characters with the default font.

if i want to write Asian characters, i need to set below fonts(for chinese) for working fine.


Language : Chinese (Simplified)
Fonts : STSong-Light
CMap names : UniGB-UCS2-H

If i set those font some of the Europian language not able to write....

point me if done anythign wrong...

Thanks...





Change font depending on what language you need to print?

Wrapper classes that hold information about how to print in different languages in the correct font?
Ramasamy Anbalagan
Greenhorn

Joined: Dec 14, 2009
Posts: 20
Thanks Ove for have look on my request..

hey i can able to write by specifying font for particular locale...

but i my case, i dont want to write characters for particular locale.. my customer might have differenct language characters as value...i need to write all those on pdf

for example,

the value might be like this... "MyTest ä, ü, ö, ç, ê, 汉字"

The above string contains englisht and all eurpian language(Swedish, German, Portuguese, and French) as well as chinese...

how can set the font for the particular character in one string...

suggest me if any thing has to do....

Thanks...
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
my customer might have differenct language characters as value

He better not have different characters. PDFs most likely use Unicode, which is the same standard everywhere. As long as the client has fonts for all those characters, everything should just work.
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Ramasamy Anbalagan wrote:

how can set the font for the particular character in one string...



First of all, what PDF-writer are you using?

Second, why not have multiple strings with the different language-sets characters in them? This kind of the point of character sets. I don't know if the 0x005A is representing the character ¥ in ISO-8859-1 or ξ in CP737 (Greek) if I don't know what character set to use when printing, then I don't know how to interpret the bits that comes my way.

Third, I don't think you can set the font for one particular character...
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Ove Lindström wrote:I don't think you can set the font for one particular character...

Assuming a capable API such as iText is used, it's possible to set fonts on a per-character basis - PDFs support that.
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Tim Moores wrote:
Ove Lindström wrote:I don't think you can set the font for one particular character...

Assuming a capable API such as iText is used, it's possible to set fonts on a per-character basis - PDFs support that.


If you can state that so firmly, then how come you don't know how to do it??

Well, yes, you could do something like this, but it is ugly:




but then again, this is just a variant of Asian text example from iText. http://itextpdf.com/examples/iia.php?id=201
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Ove Lindström wrote:If you can state that so firmly, then how come you don't know how to do it?

You are mistaken in your assumptions about what I do and do not know.
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Tim Moores wrote:
Ove Lindström wrote:If you can state that so firmly, then how come you don't know how to do it?

You are mistaken in your assumptions about what I do and do not know.


Ok.

Could you then provide a few lines of code showing how it should be done?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Getting someone started on the way to the solution is much better than just providing the solution. It's also in the spirit of this site, I believe. We'll just have to wait and see if Ramasamy Anbalagan has further questions about this; until then, everything is just speculation.
Ramasamy Anbalagan
Greenhorn

Joined: Dec 14, 2009
Posts: 20

Sorry folks for the late response!!!

i have been tested this scenario with below code,



Testing Results is,

1. With Chinese in place, some of European characters has been disappear and Chinese character is displaying as expected.
2. With Japanese in place, we could see things working well (some of the European character only we tested, it's all coming). I am not sure whether other than tested character will display while using Japanese font and Japanese characters is displaying as expected
3. With Korean in place, we couldn’t see any of the European characters and Korean characters is displaying as expected

My requirement is, we want write it all together with European language characters.

Hope you will understand my issue. Can someone point me how to resolve this.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Does this font: BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED) include all the characters you're trying to display? Have you tried a "universal" font like Arial Unicode MS (or some such name, it comes with Microsoft Office)?
Ramasamy Anbalagan
Greenhorn

Joined: Dec 14, 2009
Posts: 20
That font was included for chinease character not for all characters. since we are not able to set the font for character specific, we were set the font like those and tried whether those font is supporting all other characters.

Have you tried a "universal" font like Arial Unicode MS (or some such name, it comes with Microsoft Office)?

>>Also i dind't try this font.. i believe we need CMap names for apply those font on below

BaseFont.createFont("Arial Unicode MS ", ? , BaseFont.NOT_EMBEDDED)
Ramasamy Anbalagan
Greenhorn

Joined: Dec 14, 2009
Posts: 20
Guys,

Can any one help me on the above task..

Thanks..
 
Consider Paul's rocket mass heater.
 
subject: How to write single byte and double byte characters on pdf using java api(iText)
 
Similar Threads
iText PDF generation- Russian characters not visible
Unicode(UTF-8) to PDF using iText
Internationalization Help!
Multilingual Email - help needed
how to identify asian/european characters