Friday, 5 January 2018

Guest Post: Batch up your PDFs

Greetings fellow Editors.

My name is Owen, you may know me as "that one person out there using git to version control their scores". I've been asked to do a guest post on a feature that's new to DSE 2.6.4: command line export-to-pdf, how to use it and why you might want to.


This is fairly easy. You'll need a licenced copy of DSE, a java runtime environment installed (this is actually optional, see below), and an open command prompt (cmd.exe on Windows or Terminal on Mac/*nix). At your prompt, type the following command:

java -jar <path to DSE jar> createPDF <path to .ds file> <path to .pdf file>

The <path to ...> bits can be either absolute (starting with a / or drive letter), or relative to your current location. You may find it useful to run the command from either the folder holding your .ds files, or the folder you want the .pdf to appear in. I'm on Windows and I like to keep my .ds files separate from the corresponding .pdf files, so I run my command from the folder that contains both the .ds folder and the .pdf folder, and it looks like this:

java -jar "C:\Program Files (x86)\DrumScoreEditor\app\DrumScoreEditor-2.6.4.jar" createPDF Scores\3-4March.ds PDFs\Retreats.pdf

If you don't already have java installed (and don't want to get it), you can invoke the application directly:

<path to DSE executable> createPDF <path to .ds file> <path to .pdf file>

In this case, however, the file paths will need to be absolute.

Let's say you wanted to be a bit lazy, and just name the .pdf file the same as the .ds file (with the appropriate extension, of course!). In that case, you can simply specify a destination directory, and that's what'll happen:

java -jar "C:\Program Files (x86)\DrumScoreEditor\app\DrumScoreEditor-2.6.4.jar" createPDF Scores\3-4March.ds PDFs

Let's say you wanted to be really lazy, and do all the .ds files in a folder, exporting them to .pdf files of the same name. In that case, you can simply specify source and destination directories, and that's what'll happen.

java -jar "C:\Program Files (x86)\DrumScoreEditor\app\DrumScoreEditor-2.6.4.jar" createPDF Scores PDFs

This is actually far more efficient than doing the files one at a time, because the overhead of starting up the program only happens once.


This is a little harder to answer. On its own, this probably isn't going to make anybody's life easier. If you're editing a drum score, then it's actually less effort to go File -> Export -> Export as pdf... than it is to open up a command prompt and do all that typing. But the beauty of being able to run a command to do this is that it opens up possibilities for automation.

I mentioned earlier that I am using git to keep track of the different versions of scores (I assume that mine is not the only band that likes to constantly tweak their scores!). One of the things that git can do is run user-specified sequences of commands when certain things happen, so I have configured my system such that when I'm happy with how the .ds files are, I can have git automatically do the following (using GNU make):

  • Check which files have changed, and only do the next steps for those files that have changed (this is the bread and butter of GNU make)
  • If I have two - or sometimes even three - small tunes in a set, make a new .ds file with those scores on one page (using a program I wrote myself)
  • Convert the .ds files to .pdf files (which is what this post is all about)
  • Merge multiple .pdf files into one - e.g. put a March, a Strathspey, and a Reel into a three-page MSR.pdf (using sejda [])
  • Upload any changed files to Google Drive, so that the corps can download the new score (using gdrive [])

These are all steps that I had to perform manually before setting this up, and it was often error prone; I'd forget to actually export the changed score and I'd end up uploading the same .pdf file to Google Drive, or I'd accidentally merge the .pdf files in the wrong order, or I'd make a change to a score that shares a page with another score but then forget to make the same change in the .ds file of that score alone. Now, however, all this happens automatically, so I have a much smaller chance of making a mistake.

This is really only possible with a command-line way to export a .pdf, which Alan has kindly incorporated into DSE for me in this release. Prior to this I had been using Sikulix ( to do the exports by making the mouse cursor actually do the File -> Export -> Export as pdf... movement, but it's much faster and more reliable to do it this way.

Happy Scoring!

No comments:

Post a Comment