PDF_crop: Crop white margins of a PDF file.

PDF_cropR Documentation

Crop white margins of a PDF file.

Description

PDF_crop() removes ("crops") the white margins around a PDF. It requires that pdfcrop.exe be installed and in your path. To get pdfcrop.exe, install MikTeX or Tex Live, or just use tinytex::tlmgr_install('pdfcrop').

Usage

PDF_crop(
  input,
  dirOutput = NULL,
  outputExtension = "_crop",
  deleteOriginal = TRUE,
  openCropped = FALSE,
  verbose = FALSE
)

Arguments

input

A string. Path and name of file to be cropped. If input does not end with ".pdf", ".pdf" will be appended to it. This is the only required argument.

dirOutput

A string. Path of directory into which cropped file should be placed.

outputExtension

A string. The new file will have the same name as the old file, except that outputExtension will be inserted just before the ".pdf" extension.

deleteOriginal

Logical, defaulting to TRUE. Should the original file be deleted?

openCropped

Logical, defaulting to FALSE. After the new file is produced, should it be opened in your default PDF viewer? Ignored on non-Windows, non-Macintosh systems.

verbose

Logical, defaulting to FALSE. If it is TRUE, two lines of information from pdfcrop.exe will be printed. They will show your version of pdfcrop.exe, the number of pages in the file that it produced, and the path and filename of the file that it produced.

See Also

knitr::plot_crop(), which is less flexible in its handling of PDF files but can handle other file formats.

Examples

## Not run: 
tmpFile <- tempfile(fileext = ".pdf")
pdf(tmpFile)
  plot(1:10, 1:10)
dev.off()
PDF_crop(tmpFile)

## End(Not run)

jbullock35/Bullock documentation built on April 1, 2022, 6:21 p.m.