Peter, I have tried using cfhttp, but am not able to get that to work either. Here is my code:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>LCAP TESTING</title>
<cfset vServer = 'http://127.0.0.1/lcapcaTesting/app/'>
<cfset vPage = '/reportsCF/reportsDocument.cfm?#SESSION.URLToken#'>
<cfhttp url="#vServer##vPage#" result="vResult">
<cfset vContent = vResult.fileContent>
</head>
<body>
<cfhtmltopdf
source="#vServer##vPage#"
pagetype="letter"
orientation="landscape"
marginTop="1" marginBottom="1" marginLeft="1" marginRight="1">
</cfhtmltopdf>
</body>
</html>
With the URL Token included, as in the code above, it errors, saying
Error occurred while generating PDF. |
| Reason: THE REFERENCE TO ENTITY "CFTOKEN" MUST END WITH THE ';' DELIMITER. |
Never have seen that before in 15 years of working with CF. Head scratcher. So, tried adding ; after the Token as in #SESSION.URLToken#; but no go, same error message.
IF the URL Token is not passed with the page, we end up with a beautiful PDF our login page (session is dropped?).
Finally, passing the vContent as the source (after the cfhttp call) as in <cfhtmltopdf source="#vContent#"... per your advice, results in a CF error page, with no information. Frustrating.
Thanks for any help. We have an extremely pressing need for a quality pdf of our content.
To start with, there is a typo. The string vServer ends with the character /, and the string vPage begins with the same character. When you concatenate the two, you get a URL that contains //.
In any case, my interpretation of Pete's suggestion is as follows:
<!--- Get contents of page --->
<cfset vServer = 'http://127.0.0.1/lcapcaTesting/app'>
<cfset vPage = '/reportsCF/reportsDocument.cfm?#SESSION.URLToken#'>
<cfhttp url="#vServer##vPage#" result="vResult">
<cfset vContent = vResult.fileContent>
<!--- Save page as HTML file --->
<cffile action="write" file="#expandPath('/lcapcaTesting/app/reportsCF/generatedContent.html')#" output="#vResult.fileContent#">
<!--- Convert HTML to PDF --->
<cfhtmltopdf
source="#expandPath('/lcapcaTesting/app/reportsCF/generatedContent.html')#"
pagetype="letter"
orientation="landscape"
marginTop="1" marginBottom="1" marginLeft="1" marginRight="1">
</cfhtmltopdf>