lilypond-user
[Top][All Lists]

## Tip for using GSview with PDF output in Windows

 From: Russ Lenth Subject: Tip for using GSview with PDF output in Windows Date: Tue, 25 Jul 2006 18:34:38 +0000 (UTC) User-agent: Loom/3.14 (http://gmane.org/)

Many people don't realize that GSview can be used to view PDF files as well as
PostScript files --- and you don't experience the font problem that people have
been encountering when viewing lilypond's .ps output.

Another advantage of GSview is that each time you make GSview the active window,
it checks to see if the file has changed -- and if so, it reloads it (while also
trying to preserve the point at which you are viewing it).  This means that, *in
principle*, you can run lilypond while keeping the pdf output open in GSview;
then see the results immediately (similar to the way xdvi works with LaTeX on a
Unix/Linux system).

However, if you try this, you get an error because part of the lilypond process
is to delete the .pdf file before replacing it with a new one -- and that can't
be done while the file is open.  But there is a way to work around this: write a
.bat file that processes the .ly file under a different name, then copies the
.pdf file to the original name.  Here is the one I wrote; it takes the base name
(without the ".ly" extension of the source file as its only argument.  This is
specific to my installation (e.g. it specifies an include directory) but it is
easily modified.

----- File LlyPd.BAT -----
@echo off

rem  This script allows compilation of a LilyPond file while the
rem  target PDF file is still open in GSview -- a situation
rem  produces an error with the ordinary lilypond command.

rem Usage:  llypd basename
rem         (DON'T include the extension ".ly")

copy /Y %1.ly 00temp00.ly
c:\progra~1\lilypond\usr\bin\lilypond -Ic:/work/music/include 00temp00.ly

rem  If it was successful enough to produce a pdf file, copy it over
rem  and delete the temp file(s) produced

if not exist 00temp00.pdf goto finish
copy /Y 00temp00.pdf %1.pdf
del 00temp00.ps
del 00temp00.pdf

:finish
del 00temp00.ly
----- end of file -----

A more refined way to write this would be to use the -o or --output option;
however, this option does not seem to work correctly with my current
installation (version 2.9.12 for Windows XP).

I don't know if a similar method works for the gui version (lilypond-windows).
I use the command-line version because I can add it to the Tools menu of my text
editor (TextPad) and capture the output in another TextPad window.  I recommend
TextPad for Windows users who do a lot of programming (including things like
LilyPond and LaTeX).

Russ