7 Replies Latest reply on Jun 7, 2014 12:33 AM by Anit_Kumar

    Problems with CFHTMLTOPDF

    gtheobald Level 1

      Working with this tag for the first time in a trial version of CF 11. I'm unable to pass any URL vars with the source without error, for both .cfm and .html pages. For example, source="myPage.html" works as expected, but source="myPage.html?x=1" throws a 500 error.

      When the urltoken is not passed with the source when the source is a .cfm page, the session (login) is not recognized and we get thrown to the login page.

        • 1. Re: Problems with CFHTMLTOPDF
          BKBK Adobe Community Professional & MVP

          Gtheobald wrote:

           

          "myPage.html?x=1"

          I can imagine why this fails. Why would you pass a URL variable to a static page?

          • 2. Re: Problems with CFHTMLTOPDF
            gtheobald Level 1

            BKBK: Thanks for taking time to respond.  The reality is, it does fail, and the point being that it fails only when a URL var is included in the "source".  You are correct that it is not relevant to pass a URL var to a static page, that was only an example, but is also the way I discovered what the true problem is.  My actual code is below, and we must pass the SESSION.URLToken to maintain the user session.

             

            <cfset vPage = 'reportsDocument.cfm?#SESSION.URLToken#&reportType=4'>

             

            <cfhtmltopdf

              source="#vPage#"

              pagetype="letter"

              orientation="landscape"

              marginTop="1" marginBottom="1" marginLeft="1" marginRight="1">

             

            </cfhtmltopdf>

            • 3. Re: Problems with CFHTMLTOPDF
              pete_freitag Adobe Community Professional

              Sounds like they are stripping out the query string for whatever reason. You probably should file a bug report. As a workaround you can use cfhttp to get the HTML and then pass the html to cfhtmltopdf

              • 4. Re: Problems with CFHTMLTOPDF
                gtheobald Level 1

                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.

                • 5. Re: Problems with CFHTMLTOPDF
                  BKBK Adobe Community Professional & MVP

                  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>

                  • 6. Re: Problems with CFHTMLTOPDF
                    gtheobald Level 1

                    Thanks BKBK and Pete.  We are up and running with the <cfhttp> workaround.  I wonder if others are running into similar issues with <cfhtmltopdf>.  How do we go about filing a bug report?

                    • 7. Re: Problems with CFHTMLTOPDF
                      Anit_Kumar Adobe Employee

                      You can raise a bug at Home.

                       

                      Regards,

                      Anit Kumar