我正在使用 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®');
,会发生什么? - duncan