❰❰Printing Your Stuff Again

by Jesse Herrick

January 17, 2015

The other day, I had finally decided upon a musical piece for the spring musical audition (Someone is Waiting from Company). So I decided to go online and buy the sheet music. Now, I didn’t know this at the time, but sheet music has really weird copyright laws. So I went on http://sheetmusicdirect.us/, and bought my piece.

Now I assumed that (like any person buying sheet music online for the first time) they would give me access to a PDF or something, but it turns out I had to install a plugin (yes, a plugin) for my browser to even view it. After doing that, I decided that I would print it out. So I pressed the print button and quickly started printing it. That’s when I realized that I didn’t want to print it to that printer (because it’s an inkjet and would have a lower quality than a laserjet), so I deleted it from the queue.

So I pressed the print button again. A pop-up alert appears: You have reached the total number of prints allowed for your license. That can’t be right, I thought, but it turns out (after some quick googling) that almost all online sheet music is sold with a single print. So I had a dilemma: buy the piece again (and accept that I did something stupid), or dive deep into how Mac OS X handles print requests. Being me, I chose the latter.

Unfortunately, no one had decided to write a nice blog post (like this one!) about how to reprint something cancelled on a queue. So I started learning about OS X printing, and I found out that OS X uses CUPS just like Linux.

Immediately, I browsed to http://localhost:631 and went to Jobs, then Show All Jobs. This page shows all of the jobs sent from my computer to various printers.

CUPS Print Jobs

I then clicked Reprint Job underneath Control, and my job printed again.

But I still wasn’t satisfied. That still wasn’t the printer that I really wanted, and I also wanted to have a PDF of the music. So I dove back into the CUPS documentation and found where CUPS stores its jobs. Let’s take a look:

$ sudo -s # yes, this is necessary
$ cd /var/spool/cups
$ ls
# a beautiful listing of jobs

You’ll notice a lot of files in this directory that start with a c00 is this directory. These are old print job listings, and are useless to us. However, CUPS does save the last printed job in a file starting with d00. Note that this file should have the same number as the job you saw in your browser. Mine was 113, so the file was d00113-001.

Then I took this file and copied it over to the desktop (cp d00113-001 ~/Desktop), then cded back into the desktop.

Here is where it gets a little confusing. I had this file, but had no idea what format it was in, so that I could convert it into a PDF. Eventually I found out that this is a PostScript file with the raw data needed to print the pages. So I googled and found this StackOverflow answer about converting a PostScript file to a PDF. Please give that answer an upvote if you found this useful.

Here I’ve put the command needed to convert the file. Make sure to replace the arguments after -o (output file) and -f (input file) with your arguments.

gs \
-o Name-of-Music.pdf \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/prepress \
-dHaveTrueTypes=true \
-dEmbedAllFonts=true \
-dSubsetFonts=false \
-c ".setpdfwrite <</NeverEmbed [ ]>> setdistillerparams" \
-f d00113-001

This leaves me with a high quality (and printable!) PDF of my music that I can look at wherever I like. Take that, sheet music company!

Next post: