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.


1 comment:

  1. Sadly, PDF can't be edited. After opening a PDF, the consumer can solely learn it and do nothing aside from that. That's the reason these information are of smaller measurement. If you want to learn more about this topic please visit here

    ReplyDelete