When you need to merge PDF and set password to protect PDF, the following article will be helpful for you. Merging PDF can be done from the following two aspects: merge whole PDF files into one, or only extract some pages from PDF and then merge them into one. And this method I takes is command line version, so you can do the merging and protecting PDF job together with ASP, VB, VC, Delphi, BCB, Java, .NET and COM+ codes.
The software I used here is VeryPDF HTML Converter Command Line, which can also be used as HTML Converter. Please get more information of this software on its homepage. In the following part, I will show you how to merge PDF and set password to protect PDF.
Step 1. Merge PDF
- Download HTML Converter. When go the try and buy website, you will find two versions of this software: GUI version and command line version. Please make sure download the command line version.
- When downloading finishes, please extract it to some folder then we can call the executable file in MS Dos Windows.
- When you merge PDF file, please refer to the following command line templates and parameters.
-mergepdf <string> : Merge two PDF files into one PDF file
-mergepdf "file1|file2|file3|...": Merge several PDF files into one
-mergepdf "C:\filelist.txt": Merge PDF files from a .txt file
-mergepdf "C:\test.pdf*100-200*250-300": Extract page ranges from PDF file
-mergepdf "C:\*.pdf": Merge PDF files into one PDF file
Examples:
htmltools.exe -mergepdf "C:\1.pdf|C:\2.pdf|C:\3.pdf" C:\out.pdf
htmltools.exe -mergepdf "C:\*.pdf" C:\out.pdf
htmltools.exe -mergepdf "C:\filelist.txt" C:\out.pdf
htmltools.exe -mergepdf "C:\test-extraction.pdf*10-15 C:\out10-15.pdf
htmltools.exe -mergepdf "C:\test-extraction.pdf*500-501 C:\out500-501.pdf
Step 2. Protect PDF by setting password.
- When you need to set password to protect PDF files, please refer to the following command line templates and parameters.
htmltools.exe -ownerpwd VeryPDF-keylen 2 -encryption 3900 C:\in.emf C:\out.pdf - -openpwd <string> : Set 'open password' to PDF file
-ownerpwd <string> : Set 'owner password' to PDF file
-keylen <int> : Key length (40 or 128 bit)
-keylen 0: 40 bit RC4 encryption (Acrobat 3 or higher)
-keylen 1: 128 bit RC4 encryption (Acrobat 5 or higher)
-keylen 2: 128 bit RC4 encryption (Acrobat 6 or higher)
-encryption <int> : Restrictions
-encryption 0: Encrypt the file only
-encryption 3900: Deny anything
-encryption 4: Deny printing
-encryption 8: Deny modification of contents
-encryption 16: Deny copying of contents
-encryption 32: No commenting
===128 bit encryption only -> ignored if 40 bit encryption is used
-encryption 256: Deny FillInFormFields
-encryption 512: Deny ExtractObj
-encryption 1024: Deny Assemble
-encryption 2048: Disable high res. printing
-encryption 4096: Do not encrypt metadata
So now I guess you have a clue about how to merge PDF and then protect PDF by setting password through command line. During the using, if you have any question, please contact us as soon as possible.