I have a pdf file which contains some three lines of text on the top of every page. Is there any way to remove that 2cm horizontal strip from all pages of this pdf file using any command line tool. I am using ubuntu.

  • Why not remove the text instead of resizing the page? Or is it part of an image? Mind posting it? – phk Dec 29 '16 at 15:39
  • I don't have the incovation handy, but I have done things like this using tools in the ImageMagick suite, which does handle PDFs. – DopeGhoti Dec 29 '16 at 15:47
  • It is an old scanned book. May be it was published in 1904. Its size is 220Mb. It has some dark ugly borders due to scanning. I want to trim them to save some Mb and to have a neat copy. – Rama Krishna Majety Dec 29 '16 at 15:48

PDFjam should be able to do it. It should be installable on Ubuntu with sudo apt install pdfjam. Then, move into the directory containing your PDF files and run:

for f in *pdf; do pdfjam --keepinfo --trim "2cm 0mm 0mm 0mm" --clip true --suffix "cropped" "$f"; done

That will create a cropped copy of each pdf file in the directory, where file.pdf becomes file-cropped.pdf. If you are satisfied those are correct, you can move them to a new directory (mv *-cropped.pdf newdir/) and delete the rest.

  • Sorry for delayed response and thanks for the reply. I have only one file I tried using --trim "0mm 3cm 0mm 0mm" option but the result was still each page had white space. I am editing my Question with the results. – Rama Krishna Majety Dec 30 '16 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.