PDF Page Edits – Linux CLI

PDF page edits can be pretty simple on Linux with these two command line applications that should ship with most distributions. I have it on my fedora. I’m talking about pdfseperate and pdfunite. To find out if you already have the application installed, head over to your terminal, type in pdf and hit tab, that should trigger the auto-complete for applications installed, you will see the applications that start with the name pdf, like pdftops, pdfcrop and so on. If you see these two in the list, then you are good to go. I would recommend this on small pdf files but for huge ones i would recommend something else, mainly because of the way pdfseperate operates. But then, it would still work on large files as well. You will understand why in a bit.

pdfseperate, splits all your pdf files into single pages and outputs them in a place you specify and with a name series you specify. Take a look at this example.

pdfseparate summary.pdf summarypages_%d.pdf.

What this does is to split the pdf named summary.pdf into a series of files with the name ‘summarypages’ followed by a number series. so for example if there were three pages in the summary.pdf. You will get the following files in the specified location. summarypages_1.pdf, summarypages_2.pdf, summarypages_3.pdf. It is better to make these files in a folder so that you do not crowd the existing folder, in case you have many other files on it.

Once you have this, you can unite the pages you want, in the order you want using pdfunite. For example, do something like this

pdfunite summarypages_1.pdf summarypages_3.pdf selectsummary.pdf

to unite pages 1 and 3 to a new pdf named selectsummary.pdf. But yes of course this is cumbersome, you can shorten this by saying something like

pdfunite summarypages_{1,3}.pdf selectsummary.pdf.

This also does the same thing. But now you have something short. If you have a big list, then you would probably have to enter them in the list above, like say summarypages_{1,2,5,6,9,11,14}.pdf. This is a bash functionality and does not apply only to this. You can use it anywhere on the terminal.

You now understand why i said this would not be suitable for large pdf files. Mainly because pdfseperate splits all the files into individual files. For a thousand page document you would have 1000 pages. Yes, writing it to a different folder will actually KIND OF solve the clutter. You cannot blame the pdf unite setup though. If you want to unite select pages you would anyway have to select those pages, listing them in the command above or on a seperate text file and writing a script would solve the problem. Remove the split pdf files later when you are done.

Thanks for reading.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s