PDF Generation

From 3B Knowledge
Jump to navigation Jump to search

Generating PDFs for submissions is an option available in most orgs and instances. Contact our support team if the option is not available in your installation.

Intro

Generating PDFs from document downloads/electronically signed documents is very useful, especially when we want to send out an email confirming the successful signing of a document, or simply keep a record for the audit trail.

When the option is turned on, we will create a PDF of the generated template document and save it against the Document Trace record that is created when a document is e-signed or downloaded.

How To

Traces Generate PDF option on a Template record

You can enable the option for PDFs to be generated either at the time of creating a new template by selecting the option "Traces Generate PDF", or through the template settings.

Editing the option from the template settings pop-up

Usage

PDF Generation happens only after a successful e-signature/document generation. This is an action that happens a-synchronously and as such, it may take a few seconds for the file to be generated.

If an error occurs during PDF generation, system administrator can usually access a developer log for debugging.

Considerations

Generating PDFs is notoriously difficult on the Salesforce Platform due to the constraints associated with the multi-tenant platform.


Please review the following list with considerations:

  • Styling Issues - PDFs may not always look exactly like a generated document, this is due to the way Salesforce creates PDF files using Flying Saucer java app which does not support CSS2 stylesheets and other HTML5 elements.
  • Missing Images - sometimes, images may not be added to the generated PDF, this is usually an issue with CSRF issues where the embedded image is hosted outside of Salesforce
  • Missing External Content - if you add Charts, Datatables, Calendar or other UI elements using embedded javascript functions, they may not render well due to limited CSS2 and HTML5 support
  • Pagination Issues - adding pages to a template usually works well unless you have also added a repeatable child container to the template which pulls too many records. In such scenarios, the default paging mechanism will override any custom added pages to a template
A document trace record with generated Document.pdf file

Extending to Functionality

Generating PDFs depends on the Flow "3B Docs - Generate PDFs for Document Traces" which runs a-synchronously and calls the Apex Method "Generate PDFs for Traces" which accepts a list of Document Trace ids.

The APEX Method will then get the contents of the VFP "b3d__GeneratedDocument" which is responsible for the rendering of a generated/e-signed document.