+ Start a Discussion
Ajay Dubedi 5Ajay Dubedi 5 

Issue with getContentAsPdf()

Hi Developers,

    Wonder if any one has noticed the critical update for getContentAsPdf to be considered as a HTTP Callout now onwards. How our architecture works right now is that we make a HTTP callout our very own organization and insert the content into the related list of an Object. Now this can not be possible as this is throwing the error for Recursive callout(Callout in Loop not Allowed) . i.e callout from a callout. 
    We can NOT use getContentAsPdf() in the same context as I need to do some DML and then generate the Pdf based of the changes. 
    We can NOT use future as it provides unexpected/Blank Pdf.
    What are the possible solutions that anyone might have? 

Depending on how the action is initally fired you could split the function into two transactions. EG on a visualforce page a user clicks an ajax/javascript button to get the PDF. This calls the Apex method to do the inital work (going off and getting the data). Then once that is complete you fire another Apex javascript call to generate the PDF. But this assumes its user initiated. If you are bulk calling this method you could use scheduled jobs to collect the data then generate the PDF content.