4.4.4 Other programs

When integrating LilyPond scores into documents in other software, you have to effectively mimick how lilypond-book runs lilypond.

Here we discuss how to create PNG images for use with online formats similar to HTML, and PDF and EPS for print-out formats similar to PDF.

PDF documents are usually formatted to enable printing. This means that long pieces of music must be distributed over several pages. For this mode of operation, invoke lilypond as

lilypond -dseparate-page-formats=pdf myfile.ly

This creates myfile-1.pdf, myfile-2.pdf, …, each containing a single page.

For embedding the images in a PostScript file, you can create EPS files, using -dseparate-page-formats=eps. In this case, you may also want to specify -dno-gs-load-fonts -dinclude-eps-fonts, otherwise the EPS files will not render if they are copied to another computer.

HTML documents are not printed, so they usually don’t have to worry about splitting music images across page breaks, and you can use a single (possibly very tall) image to represent a long score. This can be achieved with

lilypond -dtall-page-formats=png myfile.ly

yielding a myfile.png that has all the pages of myfile.ly stacked vertically.

Specifying either -dseparate-page-formats or -dtall-page-formats suppresses the standard output mode (single file with multiple pages) and the associated --formats option. Both options take a comma-separated list of formats and can be specified together, e.g.

lilypond -dseparate-page-formats=eps,pdf -dtall-page-formats=png,svg myfile.ly

To reduce the margins around the pages pass the -dno-use-paper-size-for-page option to crop extraneous whitespace. The following paper settings will elide page numbers and other footers that enlarge the page.

  bookTitleMarkup = ##f
  scoreTitleMarkup = ##f

… music …

The above discusses how pages are dumped into output files, but for music integrated into text, you often don’t want full pages (possibly including page numbers, margins etc.), but rather lines of music. This is achieved by including lilypond-book-preamble.ly before a fragment of music. This makes a toplevel \score block render into lines of music rather than pages.

If you need to quote many fragments from a large score, you can also use the clip systems feature, see Extracting fragments of music.

LilyPond Application Usage v2.25.10 (development-branch).