I'm kinda stuck in the middle of all the limitations Salesforce has for creating a pdf out of a Visualforce page.

What I have is a Visualforce page that takes some parameters and I use to rerender as a pdf using the getContent method inside an apex call.

The limitations I have:

  • GetContent() can not be used inside: future method, trigger, cron job
  • REST API: will cause a call out loop with the new critical update.
  • Can not use restAPI inside cron jobs, or future methods, because I can not have a valid user session.

So my what I tried to do is to generate the pdf from a cron job and email it to a certain contact. Because of all the above limitations I'm kinda stuck.

Can you think of any other solution to solve this problem?

  • Have you tried emailing it as an attachment using a batch class? That could be run from a trigger if necessary.
    – crmprogdev
    Aug 28, 2015 at 16:15
  • You have explained the issue. Can you please explain little bit more on your requirement?
    – Saroj Bera
    Aug 28, 2015 at 17:41

1 Answer 1


What's your timeline? Winter 16 will allow getcontent from @future: http://docs.releasenotes.salesforce.com/en-us/winter16/release-notes/rn_apex_pagereference_getcontent.htm

You can now make calls to the getContent() and getContentAsPdf() methods of the PageReference class from within asynchronous Apex such as Batch Apex, Schedulable and Queueable classes, and @future methods. This allows you to design much more flexible and scalable services that, for example, render Visualforce pages as PDF files.

Additionally, calls to getContent() and getContentAsPdf() that access internal Salesforce URLs are treated as internal callouts, and therefore not subject to callout limits.

  • Thanks, but one thing I noticed is that if they treat getContent() as an api call and if I'm using the REST api this will cause a api call loop.
    – raym0nd
    Aug 28, 2015 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.