pdf2png: Use 'convert' (ImageMagick) to convert PDF to high-quality...

View source: R/utils.R

pdf2pngR Documentation

Use 'convert' (ImageMagick) to convert PDF to high-quality PNG

Description

The function makes a system call to convert PDF files to high-quality (300 dpi) PNG files.

Usage

pdf2png(
  ...,
  convert = "convert",
  density = 300,
  outdir = NULL,
  outfile = NULL,
  wait = FALSE
)

Arguments

...

PDF files

convert

Name of the convert program. It is overwritten if the program is running on the udis machine (rbaus024). See the code for more details.

density

DPI. Default 300 is good enough for publications in most biology/medicine journals

outdir

Output directory. If the value is NULL, the output files will be written in the same directory as the input file

outfile

Output file names. If the value is NULL, the output file names will be basename of the input PDF files appended with the .png suffix. If given, its length must equal the length of PDF files.

wait

Logical, should the function wait until the conversion is finished?

Value

Output file names are returned invisibly.

Author(s)

Jitao David Zhang <jitao_david.zhang@roche.com>

Examples


  tmpdir <- tempdir()

  pdffile <- file.path(tmpdir, "test-plot.pdf")
  pdf(pdffile)
  plot(1:5)
  dev.off()

  pdf2png(pdffile)
  pdf2png(pdffile, outfile="test.png")

  testfile <- system.file("/doc/intro.pdf", package="limma")
  if(file.exists(testfile)) {
    pdf2png(testfile, outdir=tmpdir)
    Sys.sleep(1)
    dir(tmpdir)

   ## or waiting
    pdf2png(testfile, outdir=tmpdir, wait=TRUE)
  }


bedapub/ribiosPlot documentation built on Sept. 1, 2023, 6:50 p.m.