Merging PDF Files
This article discusses some of the free methods/tools for merging of PDF files.
PDFsam
For GUI based fans, PDFsam is a good choice with an intuitive interface.
As of now, there are 3 different versions available for download and they are Trial, Pro and Education. The Trial allows for 14 days of free usage with all capabilities enabled. After the 14 day trial, the Merge feature will still continue to function.
MergePdf
MergePdf Powershell module, written by Sergey Pavlyukovich, utilises the PDFsharp .NET open source library for merging of multiple PDFs.
The module can be installed using Powershell.
Installation
By default, the Powershell package repository is set as “untrusted”.
PS C:\> Get-PSRepository
To trust this repo, run:
PS C:\> Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install the module using:
PS C:\> Install-Module -Name MergePdf
Syntax and Usage Examples
Syntax details can be found using:
PS C:\> Get-Help Merge-Pdf
Examples of command invocations can be obtained by running:
PS C:\> Get-Help Merge-Pdf -examples
Example 1
Gets all .PDF files in current location and merges them into .\Merged.pdf
PS C:\>Merge-Pdf
Example 2
Appends in.pdf to out.pdf
PS C:\>Merge-Pdf -OutputPath c:\output\out.pdf `
-Path c:\input\in.pdf -Append
Example 3
Merges all .PDF files in current location into c:\out\out.pdf
PS C:\>Merge-Pdf -OutputPath c:\out\out.pdf
Example 4
Merges all .PDF files in folder c:\input into c:\output\out.pdf
PS C:\>Merge-Pdf -Path c:\input\ -OutputPath c:\output\out.pdf
Example5
Merges .PDF files provided from pipeline into c:\output\out.pdf
PS C:\>'c:\file1.pdf' ,'c:\file2.pdf' | `
Merge-Pdf -OutputPath c:\out.pdf
Ghostscript
Ghostscript can be downloaded from here. Once downloaded, complete the installation and add the bin
directory (in the case of Windows, the default is C:\Program Files\gs\gs9.50\bin
) to your system PATH.
Launch cmd/powershell prompt and using the following to merge your PDFs. The ^
designates a line continuation when using Windows Cmd.exe. If you are using Powershell, replace with `
c:\>gswin64 ^
-dBATCH ^
-dNOPAUSE -q ^
-sDEVICE=pdfwrite ^
-dPDFSETTINGS=/prepress ^
-sOutputFile=YourOutputPdfFile.pdf ^
YourInputfile1.pdf ^
YourInputfile2.pdf