> For the complete documentation index, see [llms.txt](https://docs.sharinpix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sharinpix.com/documentation/cookbook/merge-multiple-pdf-urls-into-a-single-merged-pdf-url.md).

# Merge multiple PDF URLs into a single merged PDF URL

## Overview&#x20;

This article demonstrates how to use the SharinPix <mark style="color:$danger;">`mergePdfUrls`</mark> Apex method and the <mark style="color:$danger;">`MergePdfUrlAutomation`</mark> 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.&#x20;

{% hint style="info" %}
**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](https://docs.sharinpix.com/faqs/how-to-update-sharinpix-package-from-the-appexchange) 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](https://docs.sharinpix.com/documentation/access-and-security/sharinpix-permission-sets).
  {% endhint %}

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

The <mark style="color:$danger;">`MergePdfUrlAutomation`</mark> 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](#configuring-the-flow-to-merge-associated-form-response-pdfs-of-a-case-record) (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](#configuring-the-flow-to-merge-associated-form-response-pdfs-of-a-case-record) below for a step-by-step walkthrough.

Additionally, we will outline how to merge multiple PDF URLs utilizing the [Apex Method](#using-this-in-apex-developer-oriented) <mark style="color:$danger;">`mergePdfUrls`</mark> (Developer-Oriented).

### Input Parameters&#x20;

| 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 <mark style="color:$danger;">`mergePdfUrls`</mark> which can be used to merge multiple PDF URLs.

### Method Signature:&#x20;

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

```apex
public class PdfMergeExample {
    public static void mergePdfDocuments() {
        //create an instance of SharinPix Utils class 
        sharinpix.Utils utils = new sharinpix.Utils();
        
        //Prepare a list of PDF URLs 
        List<String> listPdfUrls = new List<String>{
            'https://www.example.com/report1.pdf',
            'https://www.example.com/report2.pdf',
            'https://www.example.com/report3.pdf'
        };
        
        //Prepare options, currently the options support filename
        Map<String, Object> options = new Map<String, Object>{
            'filename' => 'merged_report.pdf'
        };
        
        //Merge PDF URLs. 
        String mergedUrl = utils.mergePdfUrls(listPdfUrls, options);
    }
}
```

## 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&#x20;

1. Navigate to **Setup**.
2. In the Quick Find Box, type **Flows** and select it.
3. Click New Flow and select **Record-Triggered Flow**.&#x20;
4. Click Create.

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FzxeCMAsKRS5XHx42kOJr%2Fc13e2355-755c-49b9-9480-445a4fc8a111.png?alt=media&amp;token=eb17198b-66e5-42ad-bf1d-fe6c38fd35bc" alt=""><figcaption></figcaption></figure>

### 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.**

{% hint style="danger" %}
**Warning:**

Starting with the Salesforce **Winter’26 release**, Apex Actions can no longer be executed directly in the **Run Immediately** path of a record-triggered flow. Instead, they must be placed in an **asynchronous path**, as the synchronous execution option is no longer supported.

For more details, please refer to the documentation here: [*Unable to save a flow with an Apex Action after the Salesforce Winter ’26 release – What should I do?*](https://docs.sharinpix.com/faqs/i-am-unable-to-save-a-flow-with-an-apex-action-after-the-salesforce-winter-26-release-what-should-i)
{% endhint %}

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2F4brsaAksiB1J2XADbJX9%2Fimage.png?alt=media&amp;token=c642058c-80c2-4520-8dc6-fccc469ebd84" alt=""><figcaption></figcaption></figure>

### 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 |

4. Set the **Sort Order** to **Descending** and **Sort by** to **CreatedDate.**
5. Select **All Records** to Store.

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FanIn10FAJwyXVCIXi7xG%2FForm%20Component%20Doc%20%20(14).png?alt=media&amp;token=08d5c473-5701-4528-b72e-d25ca9bcb8a1" alt=""><figcaption></figcaption></figure>

### Step 4: Loop and Build List Of URLs&#x20;

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

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FVexFHXWaj11sk6jwusTS%2Faca68ce6-6050-45cc-a2a7-c7a00ebc09d8.png?alt=media&amp;token=b5941315-bc31-46f0-9207-873d88185d3d" alt=""><figcaption></figcaption></figure>

2. Add a Loop element that will go through the Form Responses retrieved in Step 3.&#x20;

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FmsD0TjzW44qqwMoxZjmV%2Fimage.png?alt=media&amp;token=3985ec72-d84a-44d4-bc1f-9a0ab9a8fdcb" alt=""><figcaption></figcaption></figure>

3. 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](#step-4-loop-and-build-list-of-urls).

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FEQEpPLhTq7ybUA4uITcX%2Fimage.png?alt=media&amp;token=e7f4be80-ab97-4389-bb02-506ecb2a1f35" alt=""><figcaption></figcaption></figure>

It should look like this:&#x20;

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FfriOtyWq5Bq2wdZkpb7V%2Fimage.png?alt=media&amp;token=98526e02-7472-4313-b366-4c27fcb493fb" alt=""><figcaption></figcaption></figure>

### Step 5: Add the Invocable Action&#x20;

1. Add an **Apex Action** element in the **Asynchronous Path** after the loop we built in [Step 4](#step-4-loop-and-build-list-of-urls), and select the **Merge PDF URLs (MergePdfUrlAutomation)** action.

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FcgYspYELOB2ZceeQOF6Y%2Fimage.png?alt=media&amp;token=4eef3a7c-2d74-4416-ba96-6ea37bc9dea1" alt=""><figcaption></figcaption></figure>

2. Assign the variable **ListOfPdfUrls** we created in [Step 4](#step-4-loop-and-build-list-of-urls) to the **PDF URLs** input parameter.

{% hint style="info" %}
**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](https://docs.sharinpix.com/forms/advanced-form-configuration/sharinpix-forms-context-parameters.md).
{% endhint %}

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

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FNvZmHghcJ92xBPpowgzY%2Fimage.png?alt=media&amp;token=ce976207-3afd-4a90-b687-ad69790bed59" alt=""><figcaption></figcaption></figure>

### Step 6: Update the custom field Merged PDF URL&#x20;

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 style="info" %}
**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.
{% endhint %}

3. For the value, select the **Merged PDF URL** output resource received from the **Apex Action** in [Step 5](#step-5-add-the-invocable-action).

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FRFZaSIqJTRnKxqVfqly5%2Fimage.png?alt=media&amp;token=1b777164-d3bb-43ec-a995-2756ecdb07e0" alt=""><figcaption></figcaption></figure>

The final flow should look like this:

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fk2k9Lh76auvT8h7SmeXw%2Fimage.png?alt=media&amp;token=8c508f15-b37a-4e5c-bba0-8f17f8e6acba" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2F1YXNAklaUBnIkbB1AtTX%2Fimage.png?alt=media&amp;token=af1b4df6-2892-4679-8b51-90bbaa88a27b" alt=""><figcaption></figcaption></figure>

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 style="info" %}
**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](https://docs.sharinpix.com/forms/advanced-form-configuration/sharinpix-forms-context-parameters.md).
{% endhint %}

<figure><img src="https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2FxNOno8k27mrViSCPr8FO%2FForm%20Component%20Doc%20%20(13).png?alt=media&amp;token=dcb45886-462a-409e-98b3-5df592fc6407" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sharinpix.com/documentation/cookbook/merge-multiple-pdf-urls-into-a-single-merged-pdf-url.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
