Hi,
I am trying to figure out if and how I can have a mixture of English and
Chinese characters in a fixed width font.
If I use Arial Unicode MS, the Chinese characters appear to be fixed
width, at least in this small sample, but the English characters are
then not fixed width and so I do not get the alignment I am looking for.
The code snippet below will show what I am trying to accomplish I think.
The resultant PDF shows the 1st paragraph of pure Chinese characters are
properly aligned, but the 2nd paragraph of mixed Chinese/English is not
aligned.
Can anyone tell me if there is a font that will behave the way I want,
or am I barking up the wrong tree altogether? If I cannot have things
align this way can someone point me towards a better approach to solve
this problem?
For what it's worth I am using itext-1.4.5 at present.
Thanks,
Jim
String chinese =
"\u53d6\u6e96\u53d7\u4fdd\u4eba\u5728\u6574\u7684\n"
+ "\u6211\u56fd\u7ecf\u6d4e\u7ed3\u6784\u6574\u7684\n"
+ "\u8fdb\u884c\u6218\u7565\u6027\u8c03\u6574\u7684\n"
+ "\u80CC\u666F\u4e0B\uff0c\u4FE1\u606f\u4ea7\u4e1a";
String chi2 =
"HI HOW ARE YOU
\u53d6\u6e96\u53d7\u4fdd\u4eba\u5728 LAZY DOGS \u6574\u7684\n"
+ "SOME OTHER CHARACTERS
\u6211\u56fd\u7ecf\u6d4e\u7ed3\u6784 AND AGAIN \u6574\u7684\n"
+ "THE QUICK BROWN FOX
\u8fdb\u884c\u6218\u7565\u6027\u8c03 CJK SUPPORT TES\u6574\u7684\n"
+ "\u80CC\u666F\u4e0B\uff0c\u4FE1\u606f\u4ea7\u4e1a\n"
+ "\u5f53\u7d27\u8feb\u7684\u4efb\u52a1\u3002";
FontFactory.registerDirectories();
Font fontChinese = FontFactory.getFont("Arial Unicode MS",
BaseFont.IDENTITY_H, BaseFont.EMBEDDED,8);
Paragraph p = new Paragraph(chinese, fontChinese);
document.add(p);
Paragraph p2 = new Paragraph(chi2, fontChinese);
document.add(p2);
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php