Sunday, 19 June 2016

Edit PDF files in Ubuntu / remove text from PDF

Recently I had to remove a footer from a pdf document, as the document is over
100 pages and I need to do this on a monthly basis manual editing was not an option (oh and I am waaaay to lazy to do it manually)

After some research the following command line options worked like a charm:

Install qpdf and pdftk:

sudo apt-get install qpdf pdftk

Uncompress the pdf document:

qpdf --qdf --object-streams=disable source.pdf uncompressed.pdf

Then remove the text (footer) with the following sed:
sed -e "s/string to be removed/ /g" <uncompressed.pdf >removed.pdf

And lastly repair the pdf and compress it again.
pdftk removed.pdf output target.pdf compress

remember to clean up and remove all the interim files.


Monday, 6 June 2016

Easy way to determine missing file on Ubuntu

If you experience something like the following:

libXi.so.6: cannot open shared object file: No such file or directory 
apt-file can come in very handy,


sudo apt-get install apt-file 
then the following commands to identify and install the correct object containing the missing file.

sudo apt-get install apt-file 
apt-file update
apt-file search libXi.so.6 
libxi6: /usr/lib/x86_64-linux-gnu/libXi.so.6
sudo apt-get install libxi6