I wanted to buy a music book with the songs from Andrew Lloyd Webber's
Jesus Christ Superstar, but the first thing that came up in my search was
a web page with 141 SVG files, probably including everything I wanted.
But 141 SVG files would be a little inconvenient to work with, so I
thought I'd convert them to a single PDF file. There were a few Linuxy
tricks to it, so I thought I'd share it here.
To convert SVG to PDF, I used inkscape...
sudo apt install inkscape
inkscape --without-gui --file=infile.svg --export-pdf=outfile.pdf
...but that was giving an annoying warning until I ran this:
sudo apt-get install libcanberra-gtk-module
Download the 141 SVG files:
for I in {0..140} ; do wget -nv https://musescore.com/static/musescore/scoredata/gen/1/5/3/3850351/1fc07f50b82c55710a959b344e84619dc45b25be/score_${I}.svg ; done
Use inkscape to convert the SVG to PDF, preserving the vector format:
for I in {0..140} ; do echo -ne "$I\r" ; inkscape --without-gui --file=score_${I}.svg --export-pdf=score_${I}.pdf ; done
We can remove the SVG files:
rm score_*.svg
zero-pad the numbers in the PDF filenames so that they are in proper order
for globbing in the pdfunite command:
rename 's/_(\d)\./_0$1\./' score_?.pdf
rename 's/_(\d\d)\./_0$1\./' score_??.pdf
To combine the 141 PDF files into one 141-page PDF, I tried pdftk first,
but it was failing with errors, so I used pdfunite from the poppler-utils
package. If you don't have pdfunite, you can install it:
sudo apt install poppler-utils
pdfunite score_*.pdf Jesus_Christ_Superstar.pdf
Now we can remove the individual PDF files:
rm score_*.pdf
I'm glad I discovered pdfunite. It's easier to use than pdftk for merging
and it worked where pdftk failed.
Best,
Mike