I have posted other utilities for handling PDF files in previous blog posts. For example, here is a post I wrote to deal with adding or removing password protection from PDF files. The source code is available here. If you want the executables, they are here.
Recently, I needed to combine a number of PDF files into a single file so that I could password protect and email just one document. Incredibly, I could not find anything on the web that was free that allowed me to do this. So back to the PDF Sharp library and a simple console app to the rescue.
Quick start instructions:
- Put the pdf files you want to combine in folder; let’s say c:\temp
- Download and extract the executable and/or the source and compile it yourself. You will need the compiled PDFSharp.dll in the same folder as the executable.
- Open a command prompt and navigate to the folder where you have the MergePDFs.exe file.
- Execute the MergePDFs.exe file. You can add the arguments as follows; or just execute the program and it will give you the following information:
- Argument 1: Directory name where the pdf files are held. Note that all PDF files found in the source folder will be merged.
- Argument 2: Output directory and file name of the combined PDF file. If you want to use the same folder as the source folder, just key in a . and filename: “.myfile.pdf”
- Argument 3: is the sort by for the combination:
- “D” is for sort by date
- “A” is for sort by name in alpha order
- “N” is for no sort
- Argument 4: is a password to apply to the new file.
For example, to merge all PDF files in our c:\temp folder, to sort by date, and to put a password of “12345” on the document, you would execute the following:
“MergePdfs.exe c:\temp c:\targetPdfFolder\Newfile.pdf D 12345”
Disclaimer: This is a quick utility that I wrote to serve my immediate needs. It has not been fully tested and so I would not release this as a production app. But it works. However, YMMV. Post comments and questions below.