Skip to content

Commit

Permalink
add eg for images fxn of setting base directory
Browse files Browse the repository at this point in the history
and no longer set `-all` by default
  • Loading branch information
sckott committed Aug 26, 2020
1 parent 697e72f commit 840dc78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion R/pdimg_images.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#' z <- system.file("examples/Tierney2017JOSS.pdf", package="pdfimager")
#' pdimg_images(z)
#'
#' # change base directory to hold extracted images
#' x <- system.file("examples/BachmanEtal2020.pdf", package="pdfimager")
#' dir <- file.path(tempdir(), "bluetree")
#' res <- pdimg_images(x, base_dir = dir)
#'
#' # many at once
#' pdimg_images(c(x, z))
#' ## pass custom dir to each path
Expand Down Expand Up @@ -67,10 +72,12 @@ pdimg_image <- function(path, dir = NULL, ...) {
if (is.null(dir)) {
dir <- file.path(tempdir(), gsub(".pdf", "", basename(path)), "img")
} else {
# expand path in case there's a tilda or similar
dir <- path.expand(dir)
dir <- file.path(dir, gsub(".pdf", "", basename(path)), "img")
}
dir.create(dirname(dir), recursive = TRUE, showWarnings = FALSE)
res <- sys::exec_internal("pdfimages", c("-all", ..., path, dir),
res <- sys::exec_internal("pdfimages", c(..., path, dir),
error = FALSE)
err_chk(res)
if (res$status != 0) {
Expand Down
5 changes: 5 additions & 0 deletions man/pdimg_images.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 840dc78

Please sign in to comment.