Batch modification of PDF pages with magick package

Introduction

I was recently working on a PDF file with 60 odd pages and I had to crop the lower border of the pages.

ImageMagick

ImageMagick is GNU image editing program in Linux. Recently a package named magick has been created by rOpenSci.

Steps of batch manipulation of PDF pages

Loading PDF pages

The PDF pages are loaded as vector of image object

pdf <- image_read("path_file.pdf")

We can access page i with

pdf[i]

Clipping each page as batch

We run the following command to crop each page from below

pdf <- image_chop(pdf, geometry = "See documentation for the notation")

Save as the new file

image_write(pdf, "path")

Details of the magick package and resources

The documentation for magick is available here, here

The documentation for ImageMagick is available here.

Comments are welcome.

Related

comments powered by Disqus