SFDC Rich Text fields can have pictures. Overall we a are not a big fan of this but we do support them.
PDF Butler might be the only solution that supports Rich Text Pictures in a robust, rock-solid way.
If you want to use Rich Text Pictures, contact support@pdfbutler.com to get our free add-on. Make sure to provide your PDF Butler username and your OrgId when contacting us!
The class to use in the Actionable: PDFButler_Actionable_RichTextPics
Example 1: #
Let’s say, I have a rich text area field in opportunity object and I want to show the text from that field in my document. To do this, follow below steps.
- Create Data Source which queries the rich text area field from Opportunity.
- Create PICTURE LIST Data source as a child data source to the opportunity Data Source and make sure to give image name as NA(or any random text so that it should not fetch any images) as shown below. PDF Butler stores all the pictures in the rich text area field in this Data Source and generate the document.
- Create a Doc Config of type Main word document
- Open PDF Butler configuration page from the Doc Config and Upload the sample template in to the Doc Config
- Add the Opportunity Data Source, PICTURE LIST Data source as a child Data source to opportunity data source as shown below.
- Create RICH_TEXT V3 Config type for the merge field in the sample template.
- Create Actionable record as shown below for the Doc Config. Class should be PDFButler_Actionable_RichTextPics
- Open any Opportunity and add the Doc Confg id to the PDF Butler convert component and save the page
- Generate the PDF now, and you can see the pictures in the text area field are displayed in the document.
Handle Multiple Images/Large Images: #
Do you require to handle multiple and/or large Rich Text Images you might hit Salesforce Limits.
PDF Butler Image processors can work around the SFDC Limits, also for RichText Images.
Depending on your contract, there might be an extra cost, check with your Account Manager.
1. The class to use in the Actionable: PDFB_Act_RichTextPicsByUrl
2. Make sure the Actionable “When” is: After DataSources (BEFORE_BUT_AFTER_DATASOURCES)
3. Fields for the KeyValue DataSource:
pdfbutler_parentId
pdfbutler_url
Example 2: #
If you have multiple pictures in the same text area field in previous example of this article. Sometimes Salesforce might hit the limits and we will get an error in generating the document. To avoid this fetch the pictures by URL during the document generation. This can be done by following below steps.
- Create Data Source which queries the rich text area field from Opportunity.
- Instead of PICTURE LIST Data source, create a KEY VALUE Data source which holds the picture URLS.
- Create a Doc Config of type Main word document.
- Open PDF Butler configuration page from the Doc Config and Upload the sample template in to the Doc Config.
- Add the Opportunity Data Source, KeyValue Data source. Don’t forget to add pdfbutler_parentId and pdfbutler_url fields to the KeyValue Data source
- Now, create a Dynamic picture Data source as child Data source to the KeyValue Data source and map ID, URL fields as as shown below.
- Create RICH_TEXT V3 Config type for the merge field in the sample template.
- Create Actionable record as shown below for the Doc Config. Class should be PDFB_Act_RichTextPicsByUrl.
- Open any Opportunity and add the Doc Confg id to the PDF Butler convert component and save the page
- Generate the PDF now, and you can see the pictures in the text area field are displayed in the document.