Merge-PdfDocument

Merges multiple PDFs into a single PDF file.

Syntax

1
Merge-PdfDocument -Path <string[]> -Destination <string> [<CommonParameters>]

Parameters

Type

Name

Description

Default value

Optional

String[]

Path

List of PDF file paths that should be merged.

no

String

Destination

Output path of the merged PDF file.

no

Return type

Bool ← on success the cmdlet returns $true otherwise $false. On failure the Exception/ErrorMessage can be accessed using $Error.

Remarks

The order in which the PDF files are merged is specified by the order of the Path parameter.
Only PDF files specified in the Path parameter are merged.
If the destination path does point to an already existing file, the file will be overwritten but not included in the merged PDF. Otherwise a new file will be created.

Examples

Merging two PDF files

Merge-PdfDocument -Path @('$/Designs/Test1.pdf', '$/Designs/Test2.pdf') -Destination '$/Designs/Merged.pdf'

Error handling, analyze why QR Code could not be added using $Error:

1
2
3
4
5
$result = Merge-PdfDocument -Path @('$/Designs/Test1.pdf', '$/Not/Existing/File.pdf') -Destination '$/Designs/Merged.pdf'

if(-not $result){
    $Error[0].Exception #Returns: "File '$/Not/Existing/File.pdf' not found!"
}