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>
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.
On SublimeText 2, you can save a file with encoding and BOM.
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.
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!