3.5.3 Alternative output formats

The default output formats for the printed score are Portable Document Format (PDF) and PostScript (PS). Portable Network Graphics (PNG), Scalable Vector Graphics (SVG) and Encapsulated PostScript (EPS) output formats are available through command line options, see Basic command line options for LilyPond.


SVG Output

SVG output can optionally contain metadata for graphical objects (grobs) like note heads, rests, etc. This metadata can be standard SVG attributes like id and class, or non-standard custom attributes. Specify the attributes and their values by overriding a grob’s output-attributes property with a Scheme association list (alist). The values can be numbers, strings, or symbols. For example:

{
  \once \override NoteHead.output-attributes =
  #'((id . 123)
     (class . "this that")
     (data-whatever . something))
  c
}

The input above will produce the following <g> (group) tag in the SVG file:

<g id="123" class="this that" data-whatever="something">
  ...NoteHead grob SVG elements...
</g>

The <g> tag contains all of the SVG elements for a given grob. (Some grobs generate multiple SVG elements.) In SVG syntax the data- prefix is used for non-standard custom metadata attributes.


LilyPond — Notation Reference v2.23.82 (development-branch).