Print Mobile

Print

Print Mobile: How to Mobile Print from Salesforce Without Needing a PDF

Last Updated
January 16, 2025
Estimated Duration
18
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 without a PDF is recommended when your use case allows it. "Raw" or "ZPL" printing is superior for two reasons:

  • High-Speed Printing: Achieves the fastest execution-to-print time, often as low as sub-second.
  • Simplified Workflow: Eliminates the need for PDF generation in Salesforce, reducing logic complexity, dependency on external document generation tools, and pdf storage consideration in Salesforce.

When you would use PDFs over raw printing:

  • 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.

Example Implementation

Example Asset Tag Label

In this example we will be printing an asset tag from the Asset standard object in Salesforce. We will walk through the necessary changes in Salesforce to enable this. You can read along or follow exactly to reproduce this in your own org for whatever customer or standard object you require.

First, for this example and in the interest of time, we are providing sample ZPL that will be used. For a detailed walk through of how you would adjust this on your own read this guide.

^XA

^PW400
^LL200
^LH0,0
^CF0,17
^FO160,15^FDProperty of^FS
^FT0,50^A0,20,20^FB400,1,0,C^FH\^FD{!recordId.Account.Name}^FS
^CF0,30
^FO20,75^FD{!recordId.Product2.Name}^FS
^BY2,2,50
^FO30,120^BCN,40,Y,N,N^FD{!recordId.SerialNumber}^FS

^XZ

Create a Flow to Trigger Mobile Prints from Salesforce Mobile

A screen flow is used to merge in record data into the ZPL template before then triggering the mobile print.

  1. Create a New Screen Flow.
Image of selection of screen flow for flow type.

  1. Create a recordId Variable. This is needed to give the flow context of the record in which the print was triggered off of.

Image of recordId variable.
  1. Create a Text Template. Paste in the provided ZPL. Ensure you have "View as Plain Text" selected for the type.
Image of ZPL text template with merge fields.

Merge fields from records can be merged into the merge field areas. Those areas highlighted you can merge in any fields you wish to be printed. For this example we keep it simple with standard fields on the Asset object.

Image showing location of merge fields and how to search and merge in other fields.
  1. Add a Screen Element.
Screen element.
  1. Add Custom Component. Search for and drag the "Mavtron Utility Print Launcher" custom component onto the screen element.
  1. Configure Custom Component.
Image of component inputs.

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 raw printing the value for this field should be RAW. For pdf printing it would be set to PDF.

PDF Record ID: This is for the contend document record Id. This tells the package which content document should be sent for printing. In the case of raw printing, this is not relevant and can be left blank.

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.

Raw Body: This is the raw content or in this case ZPL that is being sent to be printed. This is where you would include the text template you created.

  1. Save and Activate the Flow.

Create a Button to Trigger the Print.

  1. Navigate to object manger in setup for the Asset object.
  2. Click on Buttons Links and Actions.
Image of the Buttons, Links, and Actions section.
  1. Create the Button.
Image of creating the action in object manager for the Asset standard object.
  1. Drag and Drop the Action on the Page Layout.
Image of the Page Layout and the action added.

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.

Image of created action on Salesforce Mobile.