Learn R Programming

staplr (version 2.9.0)

select_pages: Select pages from a file

Description

If the toolkit Pdftk is available in the system, it will be called to combine the selected pages in a new pdf file.

See the reference for detailed usage of pdftk.

Usage

select_pages(selpages, input_filepath = NULL, output_filepath = NULL,
  overwrite = TRUE)

Arguments

selpages

a vector of page numbers to be selected

input_filepath

the path of the input PDF file. The default is set to NULL. IF NULL, it prompt the user to select the folder interactively.

output_filepath

the path of the output PDF file. The default is set to NULL. IF NULL, it prompt the user to select the folder interactively.

overwrite

If a file exists in output_filepath, should it be overwritten.

Value

this function returns a PDF document with the remaining pages

References

https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

Examples

Run this code
# NOT RUN {
# This command prompts the user to select the file interactively.
# Select page 3 and 6 from the selected file.
select_pages(selpages = c(3,6))
# }
# NOT RUN {
# }
# NOT RUN {
dir <- tempdir()
require(lattice)
for(i in 1:3) {
pdf(file.path(dir, paste("plot", i, ".pdf", sep = "")))
print(xyplot(iris[,1] ~ iris[,i], data = iris))
dev.off()
}
output_file <- file.path(dir, paste('Full_pdf.pdf',  sep = ""))
staple_pdf(input_directory = dir, output_file)
input_path <- file.path(dir, paste("Full_pdf.pdf",  sep = ""))
output_path <-  file.path(dir, paste("trimmed_pdf.pdf",  sep = ""))
select_pages(selpages = 1, input_path, output_path)
# }

Run the code above in your browser using DataLab