High quality conversion of pdf page(s) to png, jpeg or tiff format, or render into a raw bitmap array for further processing in R.
Usage
pdf_render_page(
pdf,
page = 1,
dpi = 300,
numeric = FALSE,
antialias = TRUE,
opw = "",
upw = ""
)
pdf_convert(
pdf,
format = "png",
pages = NULL,
filenames = NULL,
dpi = 300,
antialias = TRUE,
opw = "",
upw = "",
verbose = TRUE
)
poppler_config()
Arguments
file path or raw vector with pdf data
- page
which page to render
- dpi
resolution (dots per inch) to render
- numeric
convert raw output to (0-1) real values
- antialias
enable antialiasing. Must be
"text"
or"draw"
orTRUE
(both) orFALSE
(neither).- opw
owner password
- upw
user password
- format
string with output format such as
"png"
or"jpeg"
. Must be equal to one ofpoppler_config()$supported_image_formats
.- pages
vector with one-based page numbers to render.
NULL
means all pages.- filenames
vector of equal length to
pages
with output filenames. May also be a format string which is expanded usingpages
andformat
respectively.- verbose
print some progress info to stdout
See also
Other cpp11poppler:
cpp11poppler
Examples
# Rendering should be supported on all platforms now
# convert pdf to png
tmpdir <- tempdir()
file <- system.file("examples", "recipes.pdf", package = "cpp11poppler")
outfiles <- paste0(tmpdir, "/apache_", 1:2, ".png")
pdf_convert(file, pages = 1:2, verbose = FALSE,
filenames = paste0(tmpdir, "/apache_%d.%s"))
#> [1] "/tmp/RtmpIClAgG/apache_1.png" "/tmp/RtmpIClAgG/apache_2.png"
page1 <- pdf_render_page(file, 1)
png::writePNG(page1, paste0(tmpdir, "/page1.png"))
webp::write_webp(page1, paste0(tmpdir, "/page1.webp"))