Fixnum.org

Blog

Print protected PDF files

For those of you who are here to crack password protected PDF files: go away. I'm not going to explain you how to do that. I am, however, going to teach you how to get past that annoying print-protection system built into PDFs.

Print protected PDF files?

PDF files are all over the Internet, often containing high quality, good looking gems of knowledge. The point of these PDF files is, of course, to print them. If not, why would you use a PDF file and not just a web page? I would make the document much easier to view and navigate.

So PDF files are meant to be printed, then why do some people prevent you from printing their PDFs? Often because they want to offer you a preview of their work, but still giving you a strong incentive to buy their books.

If this is the case with the PDFs you want to print, be aware that if you use the method below, you might be breaking laws in your country. I'm not responsible for any of your actions, and you will burn in hell for violating Adobe's precious DRM. cough

I'm going to assume you want to print a nice, legal PDF document that for some reason unknown to man has been print-protected.

The tools

Ah yes, the tools. For this little task, you will need a few tools. First of all, you need a tool called pdftoppm. This is a command line program that will convert any PDF to a series of PPM, PGM or PBM images. On Linux and *BSD, you should look for poppler-utils or xpdf-utils using the package manager of your choice. Windows users might want to look at this.

Other than that, you'll need an image viewer that can print out these images. On Linux, I use gThumb.

Now, from your favorite terminal emulator/command prompt you run:

pdftoppm your_protected_pdf_file.pdf prefix_for_image_names

and you have a shiny set of PPM images.

These tend to use up huge amounts of disk space. If you want to keep them around, you should print them to a PostScript or PDF file (Windows users: PDFCreator). If you want to convert them in gray scale to save disk space, add -gray to the command line. For monochrome images, use -mono.

Concatenate PDF files with Ghostscript

I was looking for a way to concatenate PDF (or Postscript) files on Linux today, so that I could easily print some coursebook. Professors have this annoying habit of "conveniently" splitting their books into one PDF for each chapter. Very annoying if you want to print a file double-sided (like the environment-conscious geek you are).

Fortunately, Ghostscript comes to the rescue. Ghostscript comes standard with just about any Linux distribution, and can be installed on all other major operating systems as well.

To concatenate a few PDFs, simply run:

gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
-sOutputFile=out.pdf 1.pdf 2.pdf 3.pdf 4.pdf

Replace a4 by letter if you need to print on US Letter pages. It works just as well using Postscript files, of course.

Install any Linux distro from USB

It is a common misconception that installing Linux from a USB key is a difficult task. It's not. And I'm going to prove it to you in this short article.

This method is not just useful for machines without an optical drive, but it also helps you save on writeable CDs/DVDs, and it is are a lot faster during the install (copying files becomes over 10× faster on my system).

Get a Linux CD of your choice

Pick a distribution, any distribution. While I'm sure there are some that won't work, or require extra effort to work, most of them will just work. Just pick a distribution that will fit onto your USB key. I mostly use network install disks, because they fit on my USB key without eating up too much space, so I can still use it for something else.

I've tried Fedora Core 8, Arch Linux, Xubuntu, Ubuntu, CentOS and Debian so far. All of them worked fine.

Mount it

On Linux, simply run (as root):

mount -o loop /path/to/iso-file /mnt

Use a tool like Virtual Clone Drive if you're stuck on Windows.

Format your USB key

Format your USB key to VFAT if it isn't already formatted that way. If you don't know what this means, then you can safely skip this step. If your new to linux, Windows uses VFAT for all USB keys, so you're safe.

Note that if it's VFAT-formatted, you don't have to format it or remove the other files on your USB key. The installer can safely live next to your data.

On Linux format the disk like this (as root, again):

mkfs.vfat /dev/sdX1

where X is replaced by the letter of your USB key. If you're not smart enough to find out which letter that is, ask someone else. Use a forum, go on IRC.

Run syslinux

Now that your key has the right filesystem, we can install the boot loader on it. A boot loader is a piece of software that tells your computer how to start running an operating system. On USB keys, there really isn't much choice. If you want to boot Linux, syslinux is the only way to go. Do this as root:

syslinux /dev/sdX

where X is the same as before.

Note: you only have to do this once each time you format your key. You can just skip all of the above steps and delete the data from the install CD of a distribution and follow the steps below for another distribution if you want to switch to some other distro.

Copy over the files

Copy the files from the mounted CD image to the USB key. Don't worry about how you do this, VFAT isn't smart enough to handle permissions or anything anyway.

You may have to mount the USB key manually, depending on your system.

The magic trick

Now we need to make the changes to the contents of the live CD that were copied onto your USB key. I'm going to be assuming you're using an up to date version of syslinux, because the old ones have some issues I don't feel like discussing.

To make it bootable, just see if there is a isolinux dir in the root of the USB key. If there is, rename it to syslinux. Also rename isolinux.cfg and isolinux.bin inside the folder to syslinux.cfg and syslinux.bin, respectively.

If there is no isolinux directory, check if the two files above are in the root directory themselves. If they are, just rename them and leave them there.

If you can't find either the directory or the files in the root of the key, you'll have to look for them elsewhere. If you find them, just copy the directory they're in to the root of the USB key and rename the directory and files to syslinux, syslinux.cfg and syslinux.bin.

Installing

Now your USB key should be good to go. Configure your BIOS to boot from your USB disk first, and enjoy.

This page was last updated on 06/02/2008
© Wim Vander Schelden, 2006-2008