首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Railo PDF生成问题

Railo PDF生成问题
EN

Stack Overflow用户
提问于 2012-07-22 10:44:33
回答 2查看 1.9K关注 0票数 3

我是铁道部的新手。试图在“Railo”上建立一个应用程序时,我遇到了PDF生成方面的问题。注意,我在上运行这个应用程序没有问题。

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

我不想再使用了。

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

事先非常感谢,

汤姆

希腊

cfc只提供数据库中的数据。

我正在使用的代码:

代码语言:javascript
运行
复制
<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>
EN

回答 2

Stack Overflow用户

发布于 2013-02-25 14:15:02

铁道在某些方面是不同的。非常重要的是,生成PDF的CFC / CFM文件也要以unicode格式保存。

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

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

如果你这么做的话,它应该能用。

听起来很奇怪..。但试试看。它修复了我的UTF-8应用程序在铁路上很多次。

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

在SublimeText 2上,可以使用编码和BOM保存文件。

在ColdFusion生成器中,不确定BOM设置的确切位置,但这里是一个首选项,以确保默认编码设置为UTF-8。

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

祝好运!

票数 0
EN

Stack Overflow用户

发布于 2013-11-18 18:52:00

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11599597

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档