The described integration method was tested with ColdFusion MX 6.1 enterprise and development editions running under Jrun4
Making PD4ML available in ColdFusion web application.
Copy pd4ml.jar, pd4ml_tl.jar and pd4ml.tld (pd4ml_demo.jar, pd4ml_tl_demo.jar and pd4ml.tld) to the directory WEB-INF/lib of your CF-enabled application. By default it is ${jrun4}/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/lib.Restart the CF runtime!
Creating a PD4ML-enabled .cfm page
<cfimport taglib="/WEB-INF/lib/pd4ml.tld" prefix="pd4ml"><pd4ml:transform screenWidth="400" pageFormat="A5" pageOrientation="landscape" pageInsets="15,15,15,15,points" enableImageSplit="false" inline="true" fileName="myreport.pdf" encoding="ISO8859_1" interpolateImages="false"> <pd4ml:header titleTemplate="$[title]" pageNumberTemplate="page $[page]" titleAlignment="left" pageNumberAlignment="right" color="##008000" initialPageNumber="1" pagesToSkip="1" fontSize="14" areaHeight="18"/> <html> <head> <title>Hello, CF!</title> <style> td { font-family: "Sans-Serif"; font-size: 12; } </style> </head> <body> <img src="images/logos.gif" width="125" height="74"> <p> <font face="tahoma">Hello, CF!</font> <p> <cfoutput> Today's date is #DateFormat(Now(), "dd.mm.yyyy")# </cfoutput> <p> <table border="0" width="300"> <cfloop index = "LoopCount" from = "1" to = "25"> <cfset x = variables.LoopCount mod 2 > <tr> <cfoutput> <cfif variables.LoopCount IS "1"> <td bgcolor="##d0d0d0">Euros</td> <td bgcolor="##d0d0d0">Dollars</td> <td bgcolor="##d0d0d0">Pounds</td> <cfelseif variables.x IS NOT "1"> <td>#LoopCount * 10# &##128;</td> <td>#LoopCount * 10# $</td> <td>#LoopCount / 10 * 2# £</td> <cfelse> <td bgcolor="##e7e7e7">#LoopCount * 10# &##128;</td> <td bgcolor="##e7e7e7">#LoopCount + 17# $</td> <td bgcolor="##e7e7e7">#LoopCount / 10 * 2# £</td> </cfif> </cfoutput> </tr> </cfloop> </table> </body> </html> </pd4ml:transform>
Comments:
1.There is no any white space character before <pd4ml:transform> tag. If there are any, than they appear in the resulting PDF file and corrupt it.
2.‘#’ characters have special meanings in ColdFusion. The character in the PD4ML header color definition is unescaped by duplication of ‘#’
Troubleshooting
Error: “The type for attribute authorName of tag transform could not be determined”
Solution: Jrun engine needs to be restarted. Newly installed PD4ML tag library is not known to the runtime.Error: MS Internet Explorer 6.0 and Acrobat Reader 6.0.1 (or its newer version) show blank screen instead of resulting PDF. The problem is not existent with other browsers and Acrobat Reader’s versions.
Solution: Rename your .cfm page to .pdf and add the corresponding file extensions mapping to WEB-INF/web.xml. Access the page using the new name ended with .pdf (instead of .cfm).
The extension mapping code to be added:<servlet-mapping>
<servlet-name>CfmServlet</servlet-name>
<url-pattern>*.pdf</url-pattern>
</servlet-mapping>Error: <pd4ml:page.break/> causes an error.
Solution: It seems Jrun4 does not allow dots in custom JSP tag names. To fix the issue open WEB-INF/lib/pd4ml.tld in text editor, duplicate (copy-paste) page.break tag description section. In the copied section replace page.break tag name with page_break. And than replace <pd4ml:page.break/> tags in your .cfm code with <pd4ml:page_break/>