Tutorials
Document Generation Tutorials
How to secure PDF?
in this tutorial, you’ll learn how to keep your pdf documents safe and protected we’ll explore how to apply security options while generating via automation what to expect by the end of this tutorial, you’ll be able to add security options such as passwords, printing, and edit restrictions to generated pdfs control how long your documents remain accessible to recipients prerequisites install cloudfiles in salesforce cloudfiles is available on the salesforce appexchange and can be installed using the standard app installation process check out installation docid\ aw06gffsiiq qdp1fkgcj and configuration docid\ zgbv7ll pzzzopel4 7up guides to set up your account and user access get started with setup you can secure a pdf during generation for the following options printing – (allowpdfprinting) locking the file – (lockpdf) password for edit access – (pdfownerpassword) password for viewing – (pdfviewpassword) file retention duration at the destination – (retention) allow filling fields if the generated pdf includes form fields – (allowfillingpdfformfields) 1 base screen flow before adding pdf security options, make sure you already have a basic screen flow ready you can follow the tutorial how to generate a document via screen flow with runtime variables? docid\ mhgdxvha ikmunkonbtzu to set up your flow up to the point where a document is generated this tutorial is based on a purchase order (po) example, where the po document built using a template based on the order object and is printed with runtime values entered through a screen flow your flow should at least include a screen where users can enter input values the generate document (sync) action to create the file note you can also create a screen flow without using runtime variables if your template is predefined in this tutorial, we’ll focus specifically on how to secure generated pdfs using the generate document (sync) docid 9davjkiyvj2zfhjw7zcvx action the parameters input we’ll use here can also be applied to other document generation actions for more details, check out doc generation flow actions docid\ nv27oftdk5ukedfzqpbpq 2 update destination the retention parameter only works when the generated document is saved to an external destination , such as sharepoint , onedrive , cloudfiles, etc to enable this, you’ll need to define the destination (apex defined variable), including fields like id , driveid , and library that specify where the file should be stored externally in this example, we’ll use a folder from sharepoint as the destination make sure to configure the sharepoint folder details properly in your flow for destination variable, so that the generated purchase order (po) pdf is stored there and the retention settings (like file auto deletion or expiry) can take effect 3 screen for security inputs add a new screen element in the flow before the document generation step this screen will collect user inputs for the following security settings allow pdf printing (true/false) – permits or restricts printing lock pdf (true/false) – locks pdf from edits pdf owner password – owner password to restrict editing access pdf view password – view password to restrict viewing access retention – retention duration in minutes for how long the file remains at the external destination drag checkboxes for booleans and text input for passwords into the screen 4 assign security parameters now, create an apex defined variable of type cldfs docgenparams to hold the inputs add an assignment element that assigns the values from the screen to this variable this ensures all user entered values are passed into the variable eg parameter allowpdfprinting = {!screen allowpdfprinting} parameter pdfownerpassword = {!screen pdfownerpassword} 5 update flow action edit the generate document (sync) flow action for the parameters field, select and map the apex variable you created earlier 6 activate the flow after saving all your changes, activate the flow to make it available for use add the flow to the record page ensure the flow is added to the order record page and attach the folder from the drive where the generated document will be stored to the record's cloudfiles widget test your setup navigate to the order record you want to print the purchase order (po) for and enter the inputs in the flow’s security input screen , provide values for your pdf restrictions example set allowpdfprinting = true, enter a view password , and define retention = 3 minutes once the flow completes, locate the generated file in the destination folder (e g , sharepoint, onedrive) open the pdf and verify that printing is enabled if allowpdfprinting = true the file requires the set password(s) for viewing or editing check whether the file remains available only for the specified duration for example, if retention = 3, confirm that the file is automatically removed after 3 minutes