function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AdaptiDevAdaptiDev 

Call Visualforce Page (RenderAs=PDF) from @future apex class and send PDF as email attachment

Hello,

 

I have a problem with the @Future in Apex and a VisualForce page.

 

Problem:
I need a function that can create PDF files out of a VF page and send this byEmail. And I want to processes many records (between 150 and 750 records) byclicking 1 button.

Tried this:
I have a APEX class that is executed @Future.
This Class will select some records (accounts) and then loop these records.
In this loop an existing VF page is "called"/"created" withthe record ID as parameter. This page is a VisualForce page withRenderAs="PDF".

So I just want to get a PDF file based on that VF page and the record ID.

Then I want to send out an email with some of these PDF files as attachments.

When I run this code on a selection with 1 record and I don't use @future,everything works. I recieve an email with a PDF attachment and the rightcontent is in the PDF.

When I run this code on many records and don't use @future, I get a time outerror in the browser.

When I run this code on many records and use @future, It seems to work becauseafter a while I recieve an email with many attachments, but I can not open theatatchments because they are no good PDF files and all of the same size : 2 kb. The normal PDF should be like 14 KB.

How can I fix this?

 

Kind regards,

 

Bart Caelen

Adapti 

Message Edited by AdaptiDev on 01-22-2010 05:33 AM
Message Edited by AdaptiDev on 01-22-2010 06:13 AM
icemft1976icemft1976

Ran into the same issue - did you get any resolution on this one?

DcoderDcoder

Hi All,

 

I am facing the similar issue where I am trying to create PDF attachments from VF page(rendered as PDF). Most of the records are saved as PDF attachments correctly but some of them are of 2 KB and can not be open. When I run my code to create PDFs again from those records, PDF attachment records get created correctly second time. So, it should not be an issue with record data.

 

Please advise.

 

thanks