Starting with version 2.50, VirtMus reads PDF files directly without having to convert them to image files. Furthermore, if PDF rendering is too slow, the latest versions of VirtMus have an option to automatically convert a PDF-based song to a JPG-based one. For more details see: SongLists.
If for some reason you prefer doing things by hand, follow these instructions.
If ImageMagic is installed as suggested in the
VirtMusInstall instructions, PDFs can be converted to image files by using the
convert
command.
PDFs can also be converted directly to a song file by using the script
provided by Claudio Favi and shown below.
This requires the bash
shell to be available. On Windows machines
bash
is part of the default CygWin install
#!/bin/bash
#uncomment for debug
#set -x
INPUTPDF=$1
OUTPUTJPG=${1##*/}
OUTPUTJPG=${OUTPUTJPG%.pdf}.jpg
SONGFILE=${OUTPUTJPG%.jpg}.song.xml
# NOTE: Adjust the -resize option to match the display resolution and orientation
convert -colorspace Gray -depth 8 -density 300x300 -resize x1050 "$INPUTPDF" "$OUTPUTJPG" || exit
#create the song.xml file
echo "<song>" > "$SONGFILE"
echo " <pages>" >> "$SONGFILE"
for f in "${OUTPUTJPG%.jpg}"*.jpg; do
echo " <page>" >> "$SONGFILE";
echo " <sourceFile>${f}</sourceFile>" >> "$SONGFILE";
echo " <rotation>Clockwise_0</rotation>" >> "$SONGFILE";
echo " </page>" >> "$SONGFILE";
done
echo " </pages>" >> "$SONGFILE";
echo -n "</song>" >> "$SONGFILE";
To process multiple PDF files at once:
- Save the script above to a file called
pdf2song
- Add execute permissions to the script:
chmod a+x pdf2song
- Execute the script as follows:
cd DESTDIR/
for f in ../SOURCEDIR/*.pdf; do pdf2song "$f"; done