mergePDF
This command is deprecated, use combinePDF command instead.
Combines two specified PDF files into one and stores the resulting PDF file into the variable context. The two PDFs may be from external sources or be products of other commands, such as exportPDF or this command itself.
This command is not available in Task and Batch APIs.
Attributes
var | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | String | No |
Defines the name of the variable holding the merged PDF file. |
firstDoc | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | File | Yes |
Defines the base PDF file of the merging process. In the merged result, this file's content will precede the content of |
secondDoc | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | File | Yes |
Defines the other PDF file of the merging process. In the merged result, this file's content will follow the content of |
name | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Defines a name for the merged PDF file. File suffix should not be included. If not defined, the merged PDF's name will be "merged". |
Examples
A basic example is to add an appendix to the PDF created out of your composed document. The appendix could be a resource found in your Salesforce organization, which the logic can download and then merge into your result document.
<exportPDF document="${composedDoc}" var="resultPDF"><load recordID="${appendixPDFrecord}" var="appendixPDF"><mergePDF firstDoc="${resultPDF}" secondDoc="${appendixPDF}" var="completePDF">
As the result of the merging is also a PDF file, it is possible to keep merging more documents into it. If you had more than one PDF you wish to merge into your result document, it is a good idea to store the mergedPDF into the same variable as the result document to keep the logic simpler. Like this:
<exportPDF document="${composedDoc}" var="resultPDF"><mergePDF firstDoc="${resultPDF}" secondDoc="${appendixPDF}" var="resultPDF"><mergePDF firstDoc="${resultPDF}" secondDoc="${anotherPDF}" var="resultPDF"><mergePDF firstDoc="${resultPDF}" secondDoc="${yetAnotherPDF}" var="resultPDF">
Should you have a variable amount of PDFs in a Collection to be merged, they can be merged easily with mergePDFCollection, or manually by looping through them with forEach. A specific thing to note with the loop is that due to forEach
creating its own local variable context, the merged PDF's variable needs to be created somewhere outside of the loop and the set command has to be used to store the merged result into this variable in the main context.
<exportPDF document="${composedDoc}" var="resultPDF"><forEach value="${pdfAppendices}" var="appendixPDF"><mergePDF firstDoc="${resultPDF}" secondDoc="${appendixPDF}" var="mergedPDF"><set var="resultPDF" value="${mergedPDF}">