Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Merge multiple PDF URLs into a single merged PDF URL

Overview

This article demonstrates how to use the SharinPix mergePdfUrls Apex method and the MergePdfUrlAutomation invocable action to combine multiple PDF URLs into a single merged PDF URL. You can use this feature in Salesforce Flows and custom Apex code.

Prerequisites

Before implementing it, ensure your Salesforce environment meets the following requirements:

  • Package Version: Ensure you have the SharinPix Package version 1.415 or newer installed. Follow this guide to upgrade your SharinPix Managed Package to the latest version.

  • Permissions: Users must have the SharinPix Lightning Components permission set assigned. For more information on permission sets, check SharinPix Permission Sets.

Automatically Merging PDF URLs Using Salesforce Flow (Admin-Oriented)

The MergePdfUrlAutomation is an Apex Action designed to merge multiple PDF URLs into a single URL. In the following sections, we will demonstrate how to implement this action within a Salesforce Flow (Admin-Oriented). We will configure a Flow on the Case object to automatically merge PDF URLs from related SharinPix Form responses whenever a Case status is updated to 'Escalated'. View the flow configuration below for a step-by-step walkthrough.

Additionally, we will outline how to merge multiple PDF URLs utilizing the Apex Method mergePdfUrls (Developer-Oriented).

Input Parameters

Parameter
Type
Description

PDF URLs

List<String>

The list of PDF URLs to be merged.

Filename

String

The desired filename for the merged PDF document. This parameter is optional and defaults to 'merged.pdf' if left blank.

Output Parameter

Variable
Type
Description

Merged PDF URL

String

The generated URL of the merged PDF document.

Using this in Apex (Developer-Oriented)

For custom code implementations, the SharinPix Utils class provides the method mergePdfUrls which can be used to merge multiple PDF URLs.

Method Signature:

mergePdfUrls(List<String> listPdfUrls, Map<String, Object> options)

Implementation Example

The following snippet illustrates how to instantiate the SharinPix utility class, prepare a list of URLs, define options, and execute the merge method.

Configuring the Flow to merge associated Form Response PDFs of a Case Record

Use Case: Merge all SharinPix Form Response PDF URLs linked to a Case Record into a single PDF when the field 'Status' is updated to Escalated using Salesforce Flow.

Step 1: Initialize Flow Builder

  1. Navigate to Setup.

  2. In the Quick Find Box, type Flows and select it.

  3. Click New Flow and select Record-Triggered Flow.

  4. Click Create.

Step 2: Configure the Record-Triggered Flow

  1. Select the Case object.

  2. Trigger the Flow when a record is updated.

  3. Add an entry condition with condition requirements set to All Conditions Are Met (AND) and the field Status equals Escalated.

  4. Set When to Run the Flow for Updated Records to Only when a record is updated to meet the condition requirements.

  5. Optimize the flow for Actions and Related Records.

  6. Add Asynchronous Path.

Step 3: Add a Get Records element to retrieve SharinPix Form Responses

  1. Add a Get Records element in the Asynchronous Path.

  2. Set the object to SharinPix Form Response.

  3. Set the Condition Requirements to All Conditions Are Met (AND).

Field
Operator
Value

sharinpix__PdfUrl__c

Is Null

False

sharinpix__ParentRecordId__c

Equals

Triggering Case > Case Id

  1. Set the Sort Order to Descending and Sort by to CreatedDate.

  2. Select All Records to Store.

Step 4: Loop and Build List Of URLs

  1. Create a new Resource of data type Text Collection.

  1. Add a Loop element that will go through the Form Responses retrieved in Step 3.

  1. Add an assignment element in the For Each path that will add the SharinPix Form Response PDF URL to the resource variable ListOfPdfUrls that we created in Step 4.

It should look like this:

Step 5: Add the Invocable Action

  1. Add an Apex Action element in the Asynchronous Path after the loop we built in Step 4, and select the Merge PDF URLs (MergePdfUrlAutomation) action.

  1. Assign the variable ListOfPdfUrls we created in Step 4 to the PDF URLs input parameter.

Hint The final merged PDF document will reflect the exact order of the provided URLs. For a custom sequence (like adding a cover page), structure the list of URLs in your desired order. Additionally, custom URL parameters (such as conditional visibility) are supported for the SharinPix Form Response PDF URLs. For more details, refer to SharinPix Form - Context Parameters.

  1. Specify a name in the Filename input parameter. Note: This is optional. If left blank, the default filename will be merged.pdf.

Step 6: Update the custom field Merged PDF URL

  1. Add an Update Triggering Record element after the Apex Action in the Asynchronous Path.

  2. Select the custom Merge PDF URL field that was added to the Case object.

Hint

For this example, a custom field named Merge PDF URL was added to the Case object. The data type is Text Area (Rich) with a length of 32,768.

Note: If your use case involves exceptionally long URLs, ensure you adjust the field length accordingly to prevent data truncation.

  1. For the value, select the Merged PDF URL output resource received from the Apex Action in Step 5.

The final flow should look like this:

Demo

When a Case record's Status is updated to Escalated, the Flow triggers automatically. It merges the associated Form Responses and saves the resulting merged URL into the designated custom field.

Clicking the merged URL initiates the download of the combined PDF. The image below demonstrates how the Form Responses were merged into a single PDF document.

Hint

Visibility Condition parameters were used on the first Form Response PDF URL to show the header only on the first page. For more details, refer to SharinPix Form - Context Parameters.

Last updated

Was this helpful?