Skip to contents

Convert a PDF/SVG file to images of other formats with Inkscape.

Usage

pdf2png(infile, outfile = NULL, page = NULL, dpi = 1200, white = FALSE)

pdf2svg(infile, outfile = NULL, page = NULL, white = FALSE)

svg2pdf(infile, outfile = NULL)

svg2png(infile, outfile = NULL, dpi = 1200)

Arguments

infile

String. Path to input PDF file.

outfile

Character vector. Output file paths without file extensions. File extensions will be set to .png for *2png(); .svg for pdf2svg(); and .pdf for svg2pdf(). The length of outfile should be 1 or corresponds to the length of page. If there is a mismatch, only the first element in outfile will be taken as the file stem, and the page numbers will be appended to the file stem as suffixes. By default, outfile is set to NULL, in which the input PDF file stem is used.

page

Integer vector. The pages (starting with 1) to extract from the PDF file, defaults to NULL, in which every page is converted to an image.

dpi

Integer. "Dots Per Inch" for PNG outputs with pdf2png().

Details

To use this function, inkscape has to be available from the command line. Alternatively, users can specify the absolute path to inkscape by the option stom.inkscape (e.g., options(stom.inkscape = "/home/stom/bin/inkscape")).

Examples

if (FALSE) {
infile = system.file("inkscape", "dag.pdf", package = "stom")
pdf2svg( infile, outfile="dag.svg" )
pdf2png( infile, outfile="dag.png", dpi=800 )
svg2pdf( "dag.svg", "dag2.pdf" )
svg2png( "dag.svg", "dag2.png" )
}