4 (Relatively) Easy Steps for Saving Digital Sheet Music to PDF (Mac)

How to Overcome the Single Print Limitation

I’ve had some past experience with buying digital music and the horrid software that these online companies makes you download and use for viewing the files on your local file. On top of that, if you want to print it out you only get ONE shot at printing, so you better hope that you pick a good printer and don’t run into any errors. Don’t most people just want a PDF that they can print out or keep in their Dropbox, etc? I get that there’s likely a reason for such draconian DRM for these things, but as a consumer, it’s prevented me from actually buying digital sheet music for quite a while. It’s like saying, sure you can purchase a song from iTunes, but you can only listen to it once.

So for this workaround to work you need to do a wee bit of IT legwork. It’s not very hard and I’m going to do my best to make everything crystal clear. Note: I am NOT a developer and do not speak code, so if you try this and need to troubleshoot something, don’t bother asking me, as I won’t know the answer. I got most of this information from this website, but not being a programmer, there were a few things that I didn’t understand and I actually found an easier way to do the PS to PDF conversion.

In broad strokes the workflow for this workaround is this:

  1. Print your document to a postscript (PS) file
  2. Use CUPS to identify the file
  3. Use Terminal to move the PS file to an accessible folder (e.g. Desktop)
  4. Use Preview to convert PS file to PDF

I’m a Mac user so if you’re on a PC, sorry. I can’t help you. Here the basic outline of what you need to do to get started:

  1. Enable CUPS Interface
  2. Set up a virtual printer
  3. Finding and moving files in Terminal

Enable CUPS Interface

The website I linked above just had CUPS already set up. Well, I followed the link as described there and it didn’t work. It turns out I had to turn on the CUPS interface in Terminal. If you’ve never used Terminal before it’s really not that scary, especially if you have extremely clear instructions (as I hope these will be).

So open Terminal. If you don’t know how to do that, then do a search on your machine (command-space bar, type in Terminal) and once Terminal appears, go ahead and launch it.

You will see a window appear that looks like this:

Very unglamorous yes, but it gets the job done. Now to enable CUPS on your machine, copy and paste the following command into Terminal, and press ‘return’ to execute the command:

cupsctl WebInterface=yes

Now, if you navigate to the following link, you will see the CUPS interface:

http://localhost:631/printers/

That will take you to a list of all the printers, local or networked, that are set up on your computer. For this exercise, you will need information from the jobs tab.

http://localhost:631/jobs?which_jobs=all

Once you have that up and running and can see all of you current, pending, and past print jobs.

You’ll notice that the last item in the list is a Postscript Printer. That’s the virtual printer we’ll set up next.

Set Up A Virtual Printer

In the original post about this, the person who wrote it discovered that when he canceled his print job before it was done that the data file with all the information for the document he was trying to print remained on his computer because the print job wasn’t done. The computer saved this in a postscript file.

Now, if the print job finishes, i.e., if you don’t cancel it before it’s done then the data file gets cleared from the cache. Because you only get one shot at printing the files we want to print, that process seemed a bit risky to me. In my poking around about this, I found a comment about printing directly to postscript (PS) format using a virtual printer.

Ok, so this sounds like a good workaround because the output of the print job is the very PS file that we want.

So I found a site that explained how to set up a Virtual Printer that prints directly to a PS file.

Now I know this says it’s for OS X 10.9, but I did this on a machine running Sierra (10.12.6) and had no issues.

I’ll note that as far as I can tell the address 127.0.0.1 is arbitrary, or perhaps is only relevant to the source site. Essentially what you’re doing is creating a process that is the same as printing a document and then pausing or canceling the print queue so the fact that that IP address doesn’t “work” doesn’t matter. I used it when I set up my virtual printer and was able to print a file to PS without any issues.

Finding and moving files in Terminal

OK, so we used Terminal to enable CUPS and we’re going to use it again to move the PS file to an accessible location.

CUPS stores these print queue files in a folder that you can’t access in the Finder, even if you’re an administrator. So like the source article stated, we’re going to look at the CUPS interface to determine the ID of the PS file we want. Looking at the ID next to the Postscript_Printer job you’ll see a “41”.

As the source article mentioned, there are two types of files in the /var/spool/cups directory. There are cache files, which are of no use because they have no data–these start with a “c” and are in the format “c00001” (i.e., the letter ‘c’ followed by five digits); and the data–the ones we want–start with a “d” and are of the format d000XX-001.

At this point, we want to ensure that there is a file d00041 in the /var/spool/cups directory. So back to Terminal we go.

Type the following command and press return:

sudo -s

Terminal will prompt you for your password. This is the same password attached to your user account on your computer (i.e., the master password you use to login when you turn the computer on).

Note: When you start typing nothing displays in the Terminal window. This is normal. If you enter your password incorrectly Terminal simply prompts you again until you enter the correct password.

After you enter the correct password the Terminal prompt changes to bash-3.2#

At this prompt type the following command and press return.

cd /var/spool/cups

This command simply tells Terminal to go to the /var/spool/cups directory. Terminal will prompt you with another bash-3.2# prompt.

At this point type the following command (that’s a lowercase ‘L’) and press return.

ls

(Note: As I was writing this tutorial, I realized that the d00041-001 file I needed is one that I already moved when I was testing this earlier in the day so I sent another job to the postscript printer that we can see is ID 42. Refreshing the file list for the /var/spool/cups directory shows that the data file we need, d00042-001, is in there!)

Ok, so now we know that the data file for our print job exists. Now we just need to get the file out of the directory we can’t access, and move it to one that we can access.

So I type the following command into Terminal and press return.

cp d00042-001 ~/Desktop

Voila! the PS file appears on the desktop.

(To break that command down it’s “cp” which I assume is a copy command, followed by a space, then the name of the file you want to move, followed by a space, followed by the directory you want the copied file to go to. I used ~/Desktop because it’s easy.)

Then I typed exit and pressed return to exit the sudo command. I assume this isn’t necessary, and you can just quit Terminal. If you do that before exiting, you’ll get a prompt asking you if you’re sure you want to quit because doing so would interrupt current processes (i.e. the sudo command). Because I prefer to play it safe with Terminal, I’d recommend just using the exit command and quitting.

Now navigate to the Desktop and locate your file.

Right-click (or command-click) on the file to bring up the menu for that file. The second option from the top will be ‘Open with’, select that option and a new list of applications will open. Most likely Preview will NOT be in that list, so select ‘Other…’ from the list.

This will bring up an Open menu. Change the option in the drop-down menu from ‘Recommended Applications’ to ‘All Applications’ and select ‘Preview.’

The PS file will then open in Preview. You’ll note in the menu bar for the file that it’s locked.

The final step is to go to the File menu in Preview and select Export to PDF. This will open a Save dialog and you can rename the file and save it wherever you want.

Once you know what you’re doing the entire process takes just a couple of minutes. Hopefully, this tutorial will help in that regard.

I should note that while it was digital sheet music that led me to work all of this out, there are certainly other instances where this workaround is useful.

To review:

  1. Use a virtual printer to print the document to a postscript (PS) file
  2. Use the CUPS interface to ID the job number for your document
  3. Use Terminal to move the PS file to an accessible directory
  4. Open the PS file with Preview, export to PDF

(Addendum: In doing some testing for this post I found that the instant print option for onlinesheetmusic.com saved the files on my local hard drive in PDF format. I don’t know if this is a change in practice, but you wouldn’t know it from reading their website. Regardless, if that doesn’t happen for you for some reason, or if you use a different site that hasn’t gotten smart to consumer desires yet, this workaround may still prove useful.)

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: