Skip to main content
Participant
February 25, 2021
Question

Large request - Error occurred while generating PDF. Reason: Error occurred while handling request.

  • February 25, 2021
  • 2 replies
  • 406 views

The following error is generated when trying to use cfhtmltopdf function on the page:

 

Error Occurred While Processing Request
Error occurred while generating PDF.
Reason: Error occurred while handling request.

 

- the page gets successfully generated if the <cfhtmltopdf> tags are removed

- the request generated a lot of data, which is roughly 1200 A4 pages

 

Is there a limit on the file size/number of pages when using the <cfhtmltopdf> tag?

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    February 25, 2021

    There might be something else bothering your application.

     

    I did some tests to generate a 1400-page PDF. The execution times were as follows:

     

    119 seconds

    <cfdocument format="PDF" filename="C:\Users\BKBK\Desktop\largeDoc.pdf">	
    	<cfset i=1>
        <cfloop condition="i lte 1400">
    	    <cfset i=i+1>
    		
    		<cfdocumentitem type = "footer"> Footer text <cfoutput>#cfdocument.currentpagenumber#</cfoutput></cfdocumentitem> 
    		<cfdocumentitem type = "pagebreak" /> 
        </cfloop>
    </cfdocument>

     

    12 seconds

    <cfhtmltopdf destination="C:\Users\BKBK\Desktop\largeDoc.pdf" overwrite="true">
    <cfset i=1>
        <cfloop condition="i lte 1400">
    	    <cfset i=i+1>
    	    <cfhtmltopdfitem type="header">Page: _PAGENUMBER of _LASTPAGENUMBER</cfhtmltopdfitem>		
    		<cfhtmltopdfitem type = "footer"> Footer text _PAGENUMBER</cfhtmltopdfitem> 
    		<cfhtmltopdfitem type = "pagebreak" /> 
    	 </cfloop>
    </cfhtmltopdf>

     

    Participant
    February 26, 2021

    Thank you for the replies. I will try to change the way that the pdf is produced by adding the destination parameter and see if that works.

    Community Expert
    February 25, 2021

    Wow, that's a lot of pages! I don't know if there's a strict file size limit, but you may simply be exceeding the available memory you need. I suggest trying a smaller number of pages per request, then merging them together after you've got them all.

     

    Dave Watts, Eidolon LLC

    Dave Watts, Eidolon LLC