Pull Image Attachments and Generate PDFs

You can easily insert image attachments/files that are related to a record into your PDF document. Paste the following code into the Source of the template editor where you want your pictures to appear. The LIKE test in the where clause might need to be adjusted.

Image Files

For image files, use:

<!--{{!
<lineitemsSOQL><class>none</class>
<soql>select ContentDocument.latestpublishedversionid from contentdocumentlink where linkedentityid='{{!ObjectId15}}' AND (ContentDocument.FileExtension LIKE '%jpeg')
</soql>
<column prefix="<img src='/sfc/servlet.shepherd/version/download/" postfix="' width='150px' />">ContentDocument.latestpublishedversionid</column>
</lineitemsSOQL>
}}-->

Image Attachments

For image attachments, use:

<!--{{!
<lineitemsSOQL><class>none</class>
<soql>SELECT Id FROM Attachment WHERE ParentId='{{!ObjectId15}}' AND (ContentType LIKE '%jpeg')</soql>
<column prefix="<img src='/servlet/servlet.FileDownload?file=" postfix="' width='150px' />">Id</column>
</lineitemsSOQL>
}}-->
Note: This only allows you to merge IMAGES from files or attachments. You cannot use this method to merge PDF files or attachments into your S-docs PDF.

Tags: ,

Was this helpful?