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
Kiran Kumar PunuruKiran Kumar Punuru 

Generate pdf for a custom object

Hi ,
I have a requirement like this ,I have a custom object which related to account,opportunity when a value of a field in custom object is changed from one to another i need to send an email with pdf as attachment.
The attached pdf should contains 4 tables :
1)Account Information
2)Custom Object Information
3)Opportunity Information
4)Opportunity Product Information
Can you help me how to achieve this i already tried but not getting desired result.
Thanks,
Kiran
GauravGargGauravGarg
Hi Kiran,

Are you using Custom VF page for saving Custom object record? If yes,
  • overwrite the Save button and call the apex method
  • call another VF page and send List of records using wrapper. 
  • The vf page should save the attachment as PDF. 
  • Email the PDF in vf controller. 
Hope this helps, let me know if you need more insight on this. 

Thanks,
Gaurav
Kiran Kumar PunuruKiran Kumar Punuru
Hi Gaurav,

I am not using custom VF page I am just calling email handler class on field update in that email handler i am rendering html to pdf but here all the tables and styles are not appearing in the generated PDF.

Thanks,
KiranKumar
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Kiran,
  • May I suggest You can use the renderAs option in apex: page tag.
It will look like this (below) in your VF page.
<apex:page renderAs="pdf">

Please refer the reference links below for more information on this. Hope it will be helpful.

Please mark it as best answer if the information is informative.

Thanks
Rahul Kumar
GauravGargGauravGarg
Hi Kiran,

Please add styling with border-width: 1px and other table style if required. 

hope this helps. 

Thanks,
Gaurav