Manipulating PDF Files in CLI (Split/Merge..)
On OpenIndiana, the qpdf package exists, but not on the OmniOSce repositories.
On OmniOSce, you will need to install the pkgsrc repository in order to install qpdf. You should refer to the newsletter "Install additional repositories on OmniOS ce and OpenIndiana."
Merge several PDFs into a single file:
qpdf --empty --pages file-01.pdf file-02.pdf file-03.pdf -- mergedfile.pdf
The syntax of qpdf is a bit peculiar. Actually, qpdf needs a starting file to perform the merge (like file1.pdf..). So, if you do not want to specify a starting file, you add --empty as here. Pay attention to the spaces!
Split a PDF into as many PDF files as there are pages in the PDF.
qpdf --split-pages mergedfile.pdf file-%d.pdf
Do not forget the -%d which will take the page number!
Extract a specific page from a PDF file: (example here, the second page of the mergedfile)
qpdf mergedfile.pdf --pages . 2 -- file2.pdf
Extract several contiguous pages from a PDF file (example here, extract the first and the second page of the mergedfile)
qpdf mergedfile.pdf --pages . 1-2 -- first2pages.pdf
Encrypt your PDF and create a password: (example here, we want to create the password "mygreatpassword" on the file FILE.pdf)
qpdf --replace-input --encrypt mygreatpassword mygreatpassword 256 -- FILE.pdf
qpdf, by default, wants to create a second encrypted file. The --replace-input option "converts" your original pdf file into an encrypted file, directly. You indeed need to write the password twice! It's not a mistake! 256 indicates encoding on 256 bits.
Decrypt your previously encrypted PDF! (needless to say, if you don't have the password, you won't be able to!)
qpdf --replace-input --decrypt --password=mygreatpassword FILE.pdf