These functions wrap around the utilities in the qpdf package
but alters the arguments to match this package's conventions:
the first two arguments must be input and output (which by default tempfile(fileext = ".pdf")),
all other arguments must be named,
and any pages argument is first processed by pdf_pages() (so you can also use strings like "even" or "odd").
Usage
pdf_combine(input, output = NULL, ...)
pdf_compress(input, output = NULL, ...)
pdf_overlay_stamp(input, output = NULL, ...)
pdf_rotate_pages(input, output = NULL, ..., pages = "all")
pdf_subset(input, output = NULL, ..., pages = 1L)Arguments
- input
For
pdf_combine(), a character vector of input pdf filenames. For all other functions, a single input pdf filename.- output
Output pdf filename.
NULLdefaults totempfile(fileext = ".pdf").- ...
Passed to the underlying qpdf functions.
- pages
A positive numeric vector of pages to include, a negative numeric vector of pages to exclude, or a string:
- all
Include all the pages.
- even
Include just the even pages.
- odd
Include just the odd pages.
The functions
pdf_pages()andpdf_subset()also support the string:- 2-up saddle stitch
The order of the pages to create a saddle-stitch booklet if printing 2-up.
- interleave
Interleave the first and second halves of the pages. Requires an even number of pages.
- interleave_first
Repeat the first page
n - 1times and interleave with the remainingn - 1pages.- interleave_last
Repeat the last page
n - 1times and interleave with the firstn - 1pages.
Examples
f1 <- pdf_create_blank(width = 6, height = 4)
f2 <- pdf_create_blank(width = 4, height = 6)
f3 <- pdf_combine(c(f1, f2))
f4 <- pdf_overlay_stamp(f3, stamp = f1)
f5 <- pdf_compress(f4)
f6 <- pdf_subset(f5, pages = 1L)
f7 <- pdf_rotate_pages(f6, angle = 90)
unlink(f1)
unlink(f2)
unlink(f3)
unlink(f4)
unlink(f5)
unlink(f6)
unlink(f7)