1

我使用 CFDocument 创建了一个包含日语内容的 pdf。但它没有显示日本数据。我已将 pageEncoding 用作 utf-8。它只显示空格而不是日语数据。

我使用了以下代码,

    <cfcontent type="application/pdf">
    <cfheader name="Content-Disposition" value="attachment;filename=test.pdf">
    <cfprocessingdirective pageencoding="utf-8">
    <cfdocument format="PDF" localurl="yes" marginTop=".25" marginLeft=".25" marginRight=".25" marginBottom=".25" pageType="custom" pageWidth="8.5" pageHeight="10.2">
    <cfoutput>
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
     <title>PDF Export Example</title>
     <style>
      body { font-family: Verdana; }
       </style>
    </head>
    <body>
    <h1>PDF Export Example</h1>
    <p>担当するクライエントの大半は様々な規模の企業だが、カナダの大学や政府関連の研究機関の担当経験もある。
    </p>
    <h1>PDF Export English Example</h1>
    <p>This is an example.
    </p>
    </body>
    </html>
    </cfoutput>
    </cfdocument>

请帮忙!

4

2 回答 2

3

在 PDF 中使用时,Verdana 的实现似乎不支持中文/日文。但是看起来MingLiU确实如此。我只是将其更改为使用该字体,并且通过 ColdFusion 10 一切正常。它在 Railo 中仍然无法正常工作,但我认为这是 Railo 问题,而不是 PDF / 字体问题。

因此,无论如何,只需使用专门支持您需要渲染的字形的字体。

于 2013-12-26T11:22:15.073 回答
1

几年前我遇到的东西。

为了使用 和 在 PDF 中正确呈现中文或日文字符,您应该首先在 ColdFusion 管理员 -> 设置摘要 -> Java 默认区域设置中检查您的默认区域设置。有人会认为 CFML 会尊重使用 setLocale() 的自定义语言环境,但事实并非如此。

如果是“en_US”,编辑 /lib/cffont.properties。否则,使用 cffont.properties 作为参考创建一个 /lib/cffont.properties.#locale#(例如 /lib/cffont.properties.zh_TW )。

假设在 Windows 上安装了 ColdFusion 并且客户端具有相应的字体安装。

http://henrylearnstorock.blogspot.ca/2010/08/how-to-render-chinese-japanese.html

于 2013-12-27T18:48:12.973 回答