n_pages {xmpdf} | R Documentation |
Get number of pages in a document
Description
n_pages()
returns the number of pages in the (pdf) file(s).
Usage
n_pages(filename, use_names = TRUE)
n_pages_exiftool(filename, use_names = TRUE)
n_pages_qpdf(filename, use_names = TRUE)
n_pages_pdftk(filename, use_names = TRUE)
n_pages_gs(filename, use_names = TRUE)
Arguments
filename |
Character vector of filenames. |
use_names |
If |
Details
n_pages()
will try to use the following helper functions in the following order:
-
n_pages_qpdf()
which wrapsqpdf::pdf_length()
-
n_pages_exiftool()
which wrapsexiftool
command-line tool -
n_pages_pdftk()
which wrapspdftk
command-line tool -
n_pages_gs()
which wrapsghostscript
command-line tool
Value
An integer vector of number of pages within each file.
See Also
supports_n_pages()
detects support for this feature.
Examples
if (supports_n_pages() && require("grid", quietly = TRUE)) {
f <- tempfile(fileext = ".pdf")
pdf(f, onefile = TRUE)
grid.text("Page 1")
grid.newpage()
grid.text("Page 2")
invisible(dev.off())
print(n_pages(f))
unlink(f)
}
[Package xmpdf version 0.2.1 Index]