Skip to contents

Convert an SVG string or file to multiple formats. Supported formats are:

  • "svg" - saves the SVG

  • "png" - rasterizes to PNG via svg_to_png

  • "pdf" - converts to PDF (prefers rsvg)

Usage

svg_to_formats(
  svg_input,
  output_base,
  formats = c("svg", "png"),
  dpi = 300,
  background = "transparent",
  subset_fonts = FALSE
)

Arguments

svg_input

SVG string or file path.

output_base

Base name for output files (without extension).

formats

Vector of formats to generate ("png", "svg", "pdf").

dpi

Resolution for raster formats.

background

Background color for PNG output.

subset_fonts

If TRUE, embed only the glyphs used by the SVG text (see save_svg()); mainly relevant for the "svg" output, whose file size it reduces dramatically.

Value

Named list with paths to generated files.