+ Start a Discussion
MarceldeBMarceldeB 

Create large number of PDF pages

I need to be able create a large number of PDF-rendered VF pages to send as attachments. I use getcontent for this, but this gives a timeout if called online. But getcontent is not available in @future calls or in batch jobs.

 

I have run out of ideas to get this done! Any advise?

 

to illustrate a simple version of my coding:

 

list<Messaging.EmailFileAttachment> AttList= new list<Messaging.EmailFileAttachment>();
for(ID myIDs:IDlist){
  PageReference pdf = Page.myPDFpage; // myPDFpage is VF page rendered as PDF
  pdf.setRedirect(true);
Blob b = pdf.getContent(); Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment(); efa.setFileName('mypdf.pdf'); efa.setBody(b); AttList.add(efa); } Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setToAddresses(new list<String>('mymail@mail.com')); email.setSubject('myMail'); email.setPlainTextBody('This is my mail'); email.setFileAttachments(AttList); Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});