Skip to main content
Version: 1.28 (Current)

Merge PDF

Audience: Low-code Engineers

Skill Prerequisites: Tokens

Combines two PDF files into a new PDF. All pages of the first file come first, followed by all pages of the second file. The new file is saved in a portal folder, and its URL, path and file ID can be saved as tokens for the actions that follow.

The original files aren't changed.

note

This action requires the PDF feature to be licensed.

Typical Use Cases​

  • Add a standard terms and conditions PDF to the end of a generated contract or invoice
  • Put a cover page in front of a report
  • Combine several PDFs into one download, by running the action more than once and feeding each result into the next merge

Don't use it to​

  • Copy only some pages of a PDF. Use Extract PDF instead.
  • Stamp one PDF on top of another, such as a letterhead or watermark. Use Overlay PDF instead.
  • Merge files that aren't PDFs. Both files must be PDF documents.
Action NameDescription
Generate PDFCreates a PDF from an HTML template, which can then be merged.
Extract PDFCopies selected pages of a PDF into a new file.
Overlay PDFDraws the pages of one PDF on top of another.
Send EmailSends the merged PDF as an attachment.
Delete FileDeletes the source files after merging, if they're no longer needed.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
First FileThe PDF whose pages come first. Use one of the supported file identifiers.Yesempty stringYes
Second FileThe PDF whose pages are added after the first file. Use one of the supported file identifiers.Yesempty stringYes
FolderThe portal folder where the new PDF is saved. Select a folder from the list, or switch to expression mode and enter a folder path relative to the portal root, for example Invoices/[Year]. The folder must already exist.Yesnone selectedYes
File NameThe name of the new file, without the extension. .pdf is always added, so Invoice-[OrderId] creates Invoice-1024.pdf. If empty, a random GUID is used as the name.Yesempty stringNo

Supported file identifiers​

The files must be in the portal's file system.

FormatExample
File ID77
Path relative to the portal rootDocuments/Terms.pdf
Path that includes the portal folder/Portals/0/Documents/Terms.pdf
Absolute URL of a file on the sitehttps://example.com/Portals/0/Documents/Terms.pdf
LinkClick URL/LinkClick.aspx?fileticket=...
Physical path inside the portal folderC:\inetpub\site\Portals\0\Documents\Terms.pdf

Output Parameters Reference​

Each output parameter is the name of a token to create. Leave it empty if you don't need that value.

ParameterDescription
Absolute URLToken that stores the absolute URL of the new file, for example https://example.com/Portals/0/Invoices/Invoice-1024.pdf.
Relative URLToken that stores the URL relative to the site root, for example /Portals/0/Invoices/Invoice-1024.pdf.
Physical Path TokenNameToken that stores the physical path of the new file on the server.
Link Click TokenNameToken that stores a LinkClick URL that downloads the new file.
DNN FileId TokenNameToken that stores the file ID of the new file.

Considerations​

  • Existing files are overwritten. If a file with the same name already exists in the folder, it's replaced.
  • A missing file is skipped, not reported. If one of the two files can't be found, the new PDF contains only the pages of the other file. If a file has no pages, it's skipped too. Check the identifiers if the result looks incomplete.
  • Only two files per action. To merge more, run another Merge PDF that takes the previous result (for example its DNN FileId TokenName token) as First File.
  • Password-protected PDFs aren't supported. There's no password parameter, so a PDF that needs a password to open can't be merged.
  • Merging is done with the PDFsharp library. Pages are copied as they are, including their size and orientation.

Examples​

tip

To understand how to use the below examples, please see Running Examples.

1. Add terms and conditions to a generated invoice​

This action appends Documents/Terms.pdf to an invoice whose file ID is in the InvoiceFileId token, for example one created by Generate PDF. The result is saved as Invoices/Invoice-<OrderId>.pdf, and its URL is saved in the InvoiceUrl token.

{
"Title": "Merge PDF",
"ActionType": "MergePdfs",
"Description": "Append terms and conditions to the invoice",
"Parameters": {
"FirstFileIdentifier": "[InvoiceFileId]",
"SecondFileIdentifier": "Documents/Terms.pdf",
"Folder": {
"Expression": "",
"Value": "/Invoices",
"IsExpression": false,
"Parameters": {}
},
"FileName": "Invoice-[OrderId]",
"AbsoluteUrlTokenName": "InvoiceUrl",
"RelativeUrlTokenName": "",
"PhysicalPathTokenName": "",
"LinkClickTokenName": "",
"FileIdTokenName": "MergedFileId"
}
}

After this action runs, [InvoiceUrl] can be used in an email, and [MergedFileId] can be passed to Send Email as an attachment.

Revised 09/26/2026