3

I am relatively new on Railo. Trying to set up an application on “Railo” I had encountered a problem with PDF generation. Notice I run the app on Adobe CFML Server with no problem.

The problem: Somewhere in my app I have a button that fetches data from a database and serves a downloadable PDF file. On Railo server the PDF content is returned with “funny characters”. The output language is Greek. Greek language has many accented characters. And that’s where the problem occurs (accented characters returned in a “funny” format e.g. Ÿ for ή or Š for O or OΕ’ for Ά). I think the problem is related to Railo’s fonts collection. The same manifests on openBD server! I have already tried adding cfprocessingdirective pageEncoding="utf-8" in the cfm file with no results. I have tried to add fonts in the fonts.jar (this is under \WEB-INF\lib folder) with no results also (and the call the fonts in the PDF css).

I don’t want to use Adobe CFML Server anymore.

Is there any solution on this issue?

Many thanks in advance,

Tom

Greece

The cfc just serves data from the database

The code I am using:

<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>
Jeromy French
  • 11,812
  • 19
  • 76
  • 129
  • Have you seen this mailing list thread and installed the CFDocFonts? https://groups.google.com/forum/?fromgroups#!topic/railo/oPqdov0hz6E – Jordan Jul 22 '12 at 17:02
  • As i said i have already installed new fonts. The problem is that the output of cfdocument is not what expected (accented characters outputted as "funny" characters). Although "CFDocs Fonts" plugin is very useful one. It is preferable to add new fonts in an automated fashion in contrary to decompress fonts.jar, add the new font manually and then build the jar file from scratch. So is there a way to display correctly Greek characters? Thanks in advance, Tom Greece –  Jul 23 '12 at 08:04
  • 3
    When you say the code works fine in Railo, is it running on the exact same server or are you using this test code on a different server? If you run ColdFusion on the SAME server and get this error with Railo and OpenBD, then I'd suggest submitting a bug report for each engine. Each engine strives for compatibility with Adobe CF in *most* regards (except where it doesn't make sense to do so). If the system is COMPLETELY the same, with the only difference being the CFML engine, then this is a perfect case to file a bug report. Please include your test case and full system info with the reports. – Jordan Jul 23 '12 at 22:58

2 Answers2

0

Railo is different in some ways. It is very important that the CFC / CFM file that is generating the PDF is ALSO saved in unicode format.

I recommend going to File > New in your editor and ensure that the editor allows you to define the BOM and encoding prior to creation of the file.

Then copy / paste the code into the new file and overwrite the file with it.

If you do this, it should work.

It sounds weird... but give it a shot. It's fixed my UTF-8 apps on Railo many of times.

Dreamweaver, although I no longer use it - allowed for these settings to be defined upon file creation. You can also set them in preferences for all future documents. dreamweaver preferences pane

On SublimeText 2, you can save a file with encoding and BOM. sublimetext save as encoded

In ColdFusion Builder, not sure exactly where BOM settings are located but here is a preferences pain for ensuring Default encoding is set to UTF-8. coldfusion builder preferences pane

I hope this helps you and anyone else having similar issues. REMEMBER: If you're working with UTF-8 / Railo, you have to ensure EVERY ASPECT of the interactions are also saved with UTF-8 in mind. Including the cfc/cfm files themselves.

Good luck!

Joshua F. Rountree
  • 1,462
  • 2
  • 14
  • 30
  • I know this is an old thread but: ECLIPSE does NOT set the BOM flag correctly. You can test this with a HEX editor. We maintain a German site also with bluedragon and railo. To get things to work we have a clean up script that sets the BOM flag. Eclipse also sometime moves the BOM flag into the middle of the file. I can share the code if desired. – M.Scherzer Sep 24 '14 at 11:25
0

Make sure you ALSO add the <cfprocessingdirective pageencoding="utf-8"> immediately after the <cfcomponent> in your CFC.