1

I am having some issues rendering HTML content (both English And Japanese embedded with html- CMS content) in cfdocument.

The fonts are coming up correctly, but they are being stretched (word wraps not working) and taking up extra space. Hence breaking the design in the pdf file.

I have tried using wrap, but as mentioned in this thread, I found that it operates on a string, not a fragment of HTML. So this will be an inappropriate tool for solving the issue.

I have also tried with CSS by putting the text within div tag, and applying the style width, word-wrap properties. But all above cases fails for me when used with <cfdocument format="pdf">

I have tried like below,

<cfprocessingdirective pageencoding="utf-8">
<cfset q ="英語からどれ早い中世イングランドで話され、現在世界で最も広く使用されている言語であるた西ゲルマン語です。[4]それは、英国を含むいくつかの主権国家、大多数の集団で第一言語として話されている、米国、カナダ、オーストラリア、アイルランド、ニュージーランド、カリブ海諸国の数"/>
<cfset r = "English is a West Germanic language that was first spoken in early medieval England and is now the most widely used language in the world.[4] It is spoken as a first language by the majority populations of several sovereign states, including the United Kingdom, the United States, Canada, Australia, Ireland, New Zealand and a number of Caribbean nations" />
<cfset test= q />
<cfset test1= r />
<cfdocument format="PDF" filename="./test.pdf" overwrite="Yes" fontEmbed = "yes">
<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 Combined Japanese & English (html table structure td width 400px)</h1>
<br/>
<table border="1">
<tr>
    <td style="width:400px;">#test#</td>
</tr>
</table>
<h1>PDF Export Example Combined Japanese & English (html div structure div width 400px)</h1>
<br/>
<div style="width:400px;">#test#</div>

<br/><br/><br/><br/>
<h1>PDF Export Example English (html table structure td width 400px)</h1>
<br/>
<table border="1">
<tr>
    <td style="width:400px;">#test1#</td>
</tr>
</table>    
<h1>PDF Export Example English (html div structure div width 400px)</h1>
<br/>
<div style="width:400px;">#test1#</div>
</body>
</html>
</cfoutput>
</cfdocument>
<cflocation url="./test.pdf" addtoken="false">

Please let me know if any more details are needed.

Community
  • 1
  • 1
lambypie
  • 471
  • 1
  • 12
  • 35
  • Since you did not include an example of the issue I can only assume that it has to do with the Japanese text. Maybe this will help - [Word wrap algorithms for Japanese](http://stackoverflow.com/a/2090349/1636917) – Miguel-F Jan 07 '14 at 15:06
  • I am not able find a solution with the link you have provided. I am facing the issue on wrapping Japanese content while rendering html into PDF. Is there any way to wrap Japanese using CSS or any other ways? – lambypie Jan 08 '14 at 11:21

0 Answers0