Andrew Watters

Random Linux tips and tricks

Merge, split, and/or Bates stamp PDF files on Linux

Seriously, this is one of the hardest things I have ever done. Finding the right tool was half the challenge.

I am pleased to recommend CPDF, which is free for personal and non-commercial use, but otherwise does require a license (worth it).


Merge is the default operation:

cpdf -merge file1.pdf file2.pdf -o file.pdf

Split into n-page chunks

cpdf -split -chunk 20 file.pdf -o piece%%%.pdf

Unfortunately, neither CPDF nor PDFTK can apparently split a file based on file size of the resulting chunks. This is extremely frustrating when there are file size limitations on certain courts' electronic filing systems. The solution I use is to count the number of pages (cpdf -pages file.pdf), divide by the file size in megabytes, split the PDF using that number of pages per chunk, then manually combine the resulting chunks until they are just under the file size I want. Frustrating, and begging for automation. I could probably write a script to do that, but it would be nice if there were a tool already out there.

Bates Stamp

This knowledge took me over a year and a half to obtain. I present it here for free to save others time.

cpdf -add-text "%Bates" -bates 1 file.pdf -bottomright 30 -o stamped.pdf

Change a RHEL 7 system from graphical login to shell login, and then start KDE

localhost$ sudo systemctl enable

localhost$ reboot

[After rebooting]

localhost$ startx /usr/bin/startkde

You would not believe how long it took me to figure that out. If you just do startx, it will freeze your system if there are any problems with GNOME.


Last updated: February 3, 2019

© Andrew G. Watters