Print Mobile

Print

Print Mobile: How to Print a PDF

Last Updated
January 17, 2025
Estimated Duration
25
min
Author
Ben Brumfield

Pre-Start Checklist ✅

Before getting started, make sure you have the following items at the ready:

How do I know this is the right approach for my use case?

Printing PDFs are recommended when:

  • Existing Workflow with PDFs: You already require using PDFs as a part of your business process.
  • Highly complex content: Raw printing, like ZPL, cannot support highly complex content such as tables, multi-column layouts, or intricate designs. These types of content are better suited for PDF generation tools, which are designed to handle and render complex layouts and formatting.

Otherwise, it may be worth checking out raw printing. If you're unsure, reach out us for help.

Example Implementation

In this example flow we will enable a user to select and print a PDF associated with an Account object. This can be done for any standard or custom object.

Depicted below is the final result. This solution enables the user to rapidly select and print a related PDF right from Salesforce Mobile. This flow can be adapted to support nearly any use case.

Selection and Printing of a PDF on Salesforce Mobile.

Create a Screen Flow for PDF Selection and Printing

  1. Create a recordId Variable.

Set API Name to recordId.

Set Description to This is the id of the record passed in.

Set Data Type to Text.

Check Available for input.

Click Done.

Image of recordId variable with data type Text and available for input checked.
  1. Create a formula field. This will be used to validate the recordId passed in as valid. Copy the formula below and configure the formula in flow as shown.
AND(
NOT(ISBLANK({!recordId})),
OR(
LEN({!recordId})=18,
LEN({!recordId})=15
)
)
Formula resource shown in flow.
  1. Add Decision Element. Configure as followed.
Image of decision element configuration.
  1. Handle Failure. Add Screen and handle error.
Image of flow canvas for recordId error handling.
Image of screen that displays error message.
  1. Add and Configure a Get Records Element. Get Content Document Link records as shown below.
  1. Create a Loop Element. Configure as below. This is done to....
Loop element configured in flow.
  1. Create a Collection Variable as Follows.
Collection variable to capture content document Ids.


  1. Add Assignment Element within Loop. Configure as follows. Use the newly created collection variable for the variable, use the Add operator, and then use {!Loop_Through_Related_Content_Document_Links.ContentDocumentId} for the Value.
Image of assignment element.
  1. Add a get Records. Configure as follows.
Image of get records element.
  1. Create Decision Element. This is needed to handle situations in which PDFs are not found. Configure as follows.
Image of decision element in flow to handle no PDFs found.
  1. Add Screen to Handle no PDFs Found.
Image of screen to handle no PDFs found.
  1. Add Screen to Handle Displaying Found PDFs. Configure the button as followed for the best user experience. (e.g. Changing the button to "Print")
Image of screen element configuration.
  1. Configure Data Table. Leverage a data table to make it easy for users to select the PDF they want to print.
Image of configured data table in screen component.
  1. Create Screen and Drag and Drop Custom Component. Follow instructions below for configuration.
Image of configure custom component.

API Name: The API name of the component. This can follow any naming convention you prefer.

Auto Print on Open: This determines whether or not the print triggers immediately once the user arrives at this screen. We recommend setting this to {!$GlobalConstant.True} to ensure it print immediately without requiring the user to tap a print button once more to confirm. Otherwise, setting this to {!$GlobalConstant.False} will render a button for the user to print.

Button Label: If the previous field was set to {!$GlobalConstant.False}, this field determines the label of the button text that the user will see on their screen.

Button Style: This determines the style of the button. We default to brand which is just the generic brand color in your org (often blue). Options include: success, text-destructive, destructive, outline-brand, brand, and neutral. More details can be found here.

Copies: This number determines the number of copies to be printed. If you plan to utilize copies, we recommend you read this guide for handling copies.

Type: This field tells the app if the type of printing if pdf or raw. Since this is PDF printing the value for this field should be PDF. For raw printing it would be set to RAW.

PDF Record ID: This is for the contend document record Id. This tells the package which content document should be sent for printing. We will input the selection that the use made in the data table here.

PDF Scale Mode: This tells the app whether a PDF should FIT to the media (scale automatically up or down to fit) or print exact size ACTUAL (potentially having content spill off the media). A value of FIT ensures the content scales to fit while a value of ACTUAL prints the actual size. In the case of raw printing, this field is not relevant. For this example we will put FIT.

Raw Body: This is the raw content or in this case ZPL that is being sent to be printed. When printing a PDF this field can be ignored.

Create a Button to Trigger the Print

  1. Navigate to object manger in setup for the Account object.
  2. Click on Buttons Links and Actions.
Image of Buttons, Links, and Actions button in the account object builder in setup.
  1. Create the Button.
Creation of button to trigger print.
  1. Drag and Drop the Action on the Page Layout.
Image of action dragged onto the account page layout.

All done! 🎉

You should now see the action in Salesforce Mobile. Trigger a print to test. If you run into any issues, reach out to us.