3

我对 Railo 比较陌生。尝试在“Railo”上设置应用程序时遇到了 PDF 生成问题。请注意,我在 Adob​​e CFML Server 上运行该应用程序没有问题。

问题:在我的应用程序的某个地方,我有一个按钮,可以从数据库中获取数据并提供可下载的 PDF 文件。在 Railo 服务器上,PDF 内容以“有趣的字符”返回。输出语言是希腊语。希腊语有许多重音字符。这就是问题发生的地方(重音字符以“有趣”的格式返回,例如 Ÿ 表示ή 或 Š 表示 O 或 OΕ' 表示 Ά)。我认为这个问题与 Railo 的字体集合有关。openBD 服务器上的清单相同!我已经尝试在 cfm 文件中添加cfprocessingdirective pageEncoding="utf-8"但没有结果。我试图在 fonts.jar 中添加字体(这是在 \WEB-INF\lib 文件夹下),但也没有结果(并且在 PDF css 中调用字体)。

我不想再使用 Adob​​e CFML Server。

这个问题有什么解决办法吗?

提前谢谢了,

汤姆

希腊

cfc 只提供数据库中的数据

我正在使用的代码:

<cfprocessingdirective pageEncoding="utf-8">
<cfif not IsDefined("URL.id")>
    <cfelseif not IsDefined("URL.model")>
    <cfelseif not IsDefined("URL.title")>
    <cfelseif not IsDefined("URL.id_tree")>
</cfif>
<cfheader name="Content-Disposition" value="attachment; filename=#URL.id_tree#.pdf">
<cfcontent type="application/unknown; charset=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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!---<link rel="stylesheet" type="text/css" href="resources/fonts/MinionProRegular/MinionProRegular.css" charset="utf-8" />--->
<title>Print</title>

</head>

<body>

  <!---<cfif not IsDefined("URL.id")>
      <cfelseif not IsDefined("URL.model")>
  </cfif>--->

  <!--- Get print details --->
  <cfinvoke
    component="Print"
    method="myPrint"
    returnvariable="getContent"
    id="#URL.id#" 
    model="#URL.model#">

  <!---<cfdump var="#getMember#">--->

  <!--- Output the PDF --->
  <cfdocument 
    format="pdf"
    pagetype="a4"
    <!---pageheight="5"
    pagewidth="6.5"--->
    margintop="0.6"
    marginbottom="0.8"
    marginright="1.3"
    marginleft="1"
    scale="90"
    unit="in"
    fontembed="true"
    backgroundvisible="true">

    <cfoutput query="getContent" >
    <style type="text/css">
      .logo {
          background-image:url(../../images/app-specific/ithemis_logo_NEW.png);
          background-repeat: no-repeat;
          display: inline-block;
          float: left;
          clear: right;
      }
      .name {
          font-family: Georgia, "Times New Roman", Times, serif;
          font-size: 12px;
          color: ##5a5a5a;
          <!---float: left;
          clear: right;--->
          <!---margin-top: 5px;--->
      }
      .body {
          font-family: "Times New Roman", Times, serif;

          <!---font-family: Bodoni;--->
          <!---font-family: Didot;--->
          <!---font-family: Greek;--->
          <!---font-family: Geosanslight;--->
          <!---font-family: Minionpro_regular;--->
          <!---font-family: Philosopher;--->
          <!---font-family: Russian;--->

          font-size: 11px;
          color: ##323232;
          line-height: 17px;
          <!---float: left;
          clear: right;--->
      }
      .line {
          font-size:1px;
          border-bottom-width: 1px;
          border-bottom-style: solid;
          border-bottom-color: ##202020;
          padding-bottom: 5px;
      }
      .point {
          font-family: Georgia, "Times New Roman", Times, serif;
          font-size: 11px;
          padding: 5px 5px 5px 5px;
          color: ##373737;
          background-color: ##eeeeee;
          /*width: 100% !important;*/
          display: block !important;
          text-align: justify;
      }
    </style>

      <!---<cfprocessingdirective pageencoding="utf-8">--->
      <cfdocumentitem type="header">
            <img src="../../images/app-specific/ithemis_logo_print_pdf.png" alt="iThemis logo" width="80" height="30" style="float:left;" border="0"/>
      </cfdocumentitem>
       <!---Use a footer with current page of totalpages format. --->
      <cfdocumentitem type="footer">
        <cfoutput><span style="font-family:Georgia, 'Times New Roman', Times, serif;font-size:10px;color: ##5a5a5a;float:right;">Σελίδα #cfdocument.currentpagenumber# από #cfdocument.totalpagecount#</span></cfoutput>
      </cfdocumentitem>


      <table border="0"> 

        <tr> 
            <td><span class="name">#Title#</span></td> 
        </tr>

        <tr> 
            <td><span class="body">#Body#</span></td>
        </tr> 

    </table>

    </cfoutput>
  </cfdocument>

</body>
</html>
4

2 回答 2

0

确保您还在您的 CFC中<cfprocessingdirective pageencoding="utf-8">立即添加 。<cfcomponent>

于 2013-11-18T18:52:00.627 回答
0

Railo 在某些方面有所不同。生成 PDF 的 CFC / CFM 文件也以 unicode 格式保存,这一点非常重要。

我建议在编辑器中转到文件 > 新建,并确保编辑器允许您在创建文件之前定义 BOM 和编码。

然后将代码复制/粘贴到新文件中并用它覆盖文件。

如果你这样做,它应该工作。

听起来很奇怪……但试一试。它多次修复了我在 Railo 上的 UTF-8 应用程序。

Dreamweaver,虽然我不再使用它 - 允许在文件创建时定义这些设置。您还可以在所有未来文档的首选项中设置它们。 Dreamweaver 首选项窗格

在 SublimeText 2 上,您可以保存带有编码和 BOM 的文件。 sublimetext 另存为编码

在 ColdFusion Builder 中,不确定 BOM 设置的确切位置,但这是确保默认编码设置为 UTF-8 的首选项。 Coldfusion Builder 首选项窗格

我希望这对您和其他有类似问题的人有所帮助。请记住:如果您使用的是 UTF-8 / Railo,则必须确保交互的每个方面也都使用 UTF-8 保存。包括 cfc/cfm 文件本身。

祝你好运!

于 2013-02-25T14:15:02.287 回答