【发布时间】:2013-07-01 03:25:58
【问题描述】:
我在 ColdFusion 9 中使用 iText v5 并希望包含 CopyRight 符号。文档和书籍说要传递unicode 字符串,例如\u00a9。我得到的是那个字符串,而不是符号。这是我的测试用例:
// Ask iText what version it is. This include the Registered and Copyright symbols so this
// font can obviously display them
vers = variables.javaLoader.create("com.itextpdf.text.Version").getVersion();
// Make a new paragraph and add the version number to the document
vPara = variables.javaLoader.create("com.itextpdf.text.Paragraph").init(vers);
myDoc1.add(vPara);
// Make a new string including the CopyRight symbol as per the iText docs and book
str = CreateObject("java","java.lang.String").init('Acme Products\u00a9');
// Make another paragraph and add the string to the document
para = variables.javaLoader.create("com.itextpdf.text.Paragraph").init(str);
myDoc1.add(para);
这是输出(从pdf复制):
iText® 5.4.1 ©2000-2012 1T3XT BVBA
Acme Products\u00a9
请注意已注册和版权符号正确显示在版本字符串中,以便字体可以显示它们。
我想我在这里遗漏了一些非常基本的东西,但看不到它。我知道我真的不需要创建自己的java.lang.String,因为无论如何 CF 都是这样做的,但只是为了消除这种可能性,我走了这么远。
【问题讨论】:
-
如果你只是这样做会发生什么
str = CreateObject("java","java.lang.String").init('Acme Products®');
标签: unicode coldfusion itext