compactPDF {tools}R Documentation

Compact PDF Files

Description

Re-save PDF files (especially vignettes) more compactly. Support function for R CMD build --compact-vignettes.

Usage

compactPDF(paths, qpdf = Sys.getenv("R_QPDF", "qpdf"),
           gs_cmd = Sys.getenv("R_GSCMD", ""),
           gs_quality = c("printer", "ebook", "screen"),
           gs_extras = character())

Arguments

paths A character vector of paths to PDF files, or a length-one character vector naming a directory, when all ‘.pdf’ files in that directory will be used.
qpdf Character string giving the path to the qpdf command.
gs_cmd Character string giving the path to the GhostScript executable, if that is to be used. On Windows this is the path to ‘gswin32c.exe’.
gs_quality A character string indicating the quality required: the options are respectively 300, 150 and 72dpi.
gs_extras An optional character vector of further options to be passed to GhostScript.

Details

This by default makes use of qpdf, available from http://qpdf.sourceforge.net/, including a Windows binary. If gs_cmd is non-empty, GhostScript is used.

qpdf or gs_cmd is run on all PDF files found, and those which are reduced by at least 10% and 10Kb are replaced.

The main approach of qpdf is to (losslessly) compress PDF streams. Ghostscript does that and more (including downsampling images) and consequently is much slower and may lose quality (but can also produce much smaller PDF files).

Value

An object of class c("compactPDF", "data.frame") with a format and print method. This has two columns, the old and new sizes in bytes for the files that were changed.

Note

The external tools used may change in future releases.

See Also

resaveRdaFiles.

Many other (and sometimes more effective) tools to compact PDF files are available, including Adobe Acrobat (not Reader). See the ‘Writing R Extensions’ manual.


[Package tools version 2.13.0 Index]