Recently I needed to demonstrate proof of purchasing something via my credit card statement. Easy enough, I download my most recent statement as a PDF file from American Express. Then I wanted to use Adobe Acrobat Pro’s nifty redaction features to redact all the irrelevant information from the appropriate page of the bill. Except Amex has decided that the statement should be a protected PDF, which means you can view it but cannot change it. This is of course totally bogus DRM, it’s my statement afterall! I suppose they hope to curb statement forgeries, but as anyone akamai knows: if I can view it, I can edit it. I think Preview.app on Mac OS X used to ignore DRM and let you edit protected PDFs, but doesn’t seem to on Snow Leopard.
I hunted around for a tool to unlock the PDF. There are lots of tools for Windows, which didn’t interest me. One person suggested opening the PDF and “printing” it to a PDF, but Adobe has disabled those features of the Print dialog box on Mac OS X (presumably since it would allow trivial circumvention of the DRM).
PDFKey Pro looks like a reasonable option for Mac OS X, but it is $25 which seems kinda steep for a single use. They have a downloadable demo, but it will just create an unlocked version of the first page of the PDF, which wasn’t the page I wanted. And of course I can’t edit the source PDF because it is protected, so the demo wasn’t useful to me.
Then I came upon MuPDF, which is a “lightweight PDF viewer and toolkit written in portable C”. It has an X11 GUI component, as well as command line tools. One of the command line tools is “pdfclean”, which will remove the DRM from a PDF.
Unfortunately, MuPDF isn’t in MacPorts yet, so I had to compile it by hand. It uses the Perforce jam tool instead of make, and has three library dependencies: zlib, libjpeg, and freetype2. Luckily, all of these are available in MacPorts, so I was able to install them and then edit the Jamrules
file to point at the MacPorts location. Here is the updated section of Jamrules
:
if $(OS) = MACOSX { Echo Building for MACOSX ; BUILD_X11APP = true ; CCFLAGS = -Wall -std=gnu99 -I/opt/local/include -I/opt/local/include/freetype2 ; LINKFLAGS = -L/usr/X11R6/lib -L/opt/local/lib ; LINKLIBS = -lfreetype -ljpeg -lz -lm ; APPLINKLIBS = -lX11 -lXext ; if $(BUILD) = debug { OPTIM = -g -O0 -fno-inline ; } if $(BUILD) = release { OPTIM = -O3 ; } if $(HAVE_JBIG2DEC) { LINKLIBS += -ljbig2dec ; } if $(HAVE_OPENJPEG) { LINKLIBS += -lopenjpeg ; } }
pdfclean
worked like a charm, removing the DRM from the statement. After that I was able to redact the statement without incident.
Perhaps in my copious spare time I will make a MuPDF portfile for MacPorts, but until then perhaps this will help others who want an open source way to remove bogus PDF DRM.
It seems that there is a version precompiled for Mac on the muPDF Website:
http://ccxvii.net/mupdf/download/mupdf-0.5-macosx.tar.gz
Thanks for this post, very useful. I was desperate to find an alternative to PDFkey.
Didn’t work for me. This PDF password remover for Mac OS X also worth a try:
http://mypdfsolutions.com/pdf-password-remover-mac.html
Thanks for pointing that out! I could have sworn I looked there and despite some references to the Mac OS X executable, I couldn’t find it. Perhaps I just missed it.
The link above is broken. Found it under “archive”:
http://ccxvii.net/mupdf/download/archive/mupdf-0.5-macosx.tar.gz
Thanks for pointing that out Mitchell. It appears that the developer is no longer making Mac OS X builds.
Excellent! It worked for me and thank you for the post.
Can someone walk me through how to build or compile this? I have never done this before. Thank you.
Good news Steve, there are now downloadable executables for Mac OS X that you can run directly without compiling: http://ccxvii.net/mupdf/download/mupdf-0.7-darwin-i386.tar.gz
Boy, did this save my butt! (Gotta love the Intel manuals: so big that Kinko’s can’t bind them, and yet one is prohibited from chopping the PDF into smaller chunks!) One note is that the Mac binary has moved to: http://mupdf.com/download/archive/mupdf-0.7-darwin-i386.tar.gz
Thanks again for this!
Ya MuPDF Worked awsome!
Thanks Guys!
how do you install the mupdf folder once it;s downloaded? I can’t find step by step instructions anywhere.
Walkthrough please!?
mupdf is a group of command line programs. If you have downloaded the binary version from http://mupdf.com/download/archive/mupdf-0.7-darwin-i386.tar.gz and then double-clicked the archive, you should have a folder called “mupdf-0.7-darwin-i386”. The command line tools are in that folder. If you’ve never used the Mac OS X command line, you’ll want to Google some instructions (outside the scope of this comment).
From the command line (shell), you will need to type “cd name-of-directory” where you type in the name of the directory where your mupdf folder is. Then type “cd mupdf-0.7-darwin-i386”. Once there, you can run any of the commands by typing “./commandname”. For example, if you want to unlock a protected PDF, you would type “./pdfclean locked.pdf unlocked.pdf” where locked.pdf is the name of your locked PDF file (which might need the whole path to the file if it is in a different directory) and unlocked.pdf is the name you want to save the unlocked version as.
I hope this helps.
Thank you Robert!
It helped a lot for me!
Thanks Robert.
awsome… i was wondering here and there for the past 2-3 hours and finally I reached here and it worked like a magic.
Worked like a charm! Thanks much Robert!
NOTE: It is easiest (does not require a directory path change) if you drop the PDF you would like to ‘unlock’ temporarily into the same folder as muPDF (which you have cd(ed) into already). Then you can follow the instructions exactly as Robert posted above.
Awesome, thanks a bunch. This was really helpful.
champion. thanks alot that’s all I needed!
champion. thanks alot that’s all I needed!
only thing is you put in 0.7-darwin-i386. I have “mupdf-0.5-macosx”. is the darwin version for os X? Is it more recent than the 0.5 i have?
Yes, darwin is the name for Apple’s open source Unix that underlies Mac OS X. 0.7 is a newer version, but 0.5 should also work fine for unlocking a PDF (in my experience)
YAY! Thank you all.
I’ve got: ” dyld: unknown required load command 0x80000022
Trace/BPT trap “
Thanks a lot, you’ve helped me so much. Tried many tools, and they didn’t work or were to pricey for a one time use. pdfclean made my day.
Really a useful post! And i can add one more useful software – Recover PDF Password. It helped me when i couldn’t open Pdf file, cause it was protected with user password. Without any problems I removed a password. Who have the same problem, just look
http://mac.eltima.com/pdf-password-recovery.html
Thanks to author, for a good post and
thanks for tha last advice from Darun. I tried this tool and i use it almost every day (i have a usial work with PDF docs).
please, please create a macport for this
Thanks for this. The number of academic publishers that stop you copying and pasting from articles is unbelievable. It has to be counter-productive. I’ve got over a thousand papers in my collection and at least 20% are impaired in this fashion. Not anymore!
Speaking of which can anyone tell me how to write a short shell script that would recursively use the pdfclean command on 1000 files? 😉
Pingback: Set public domain content free from locked PDF files
can anybody tell me the same software for windows? I’m planning to buy this one, has anyone tried it. Check the link
http://www.unlockapdf.com
Pingback: Adobe For Mac
On a mac, you can run the following command to create “unlocked.pdf” from “locked.pdf”:
gs -sOutputFile=unlocked.pdf -sDEVICE=pdfwrite -dNOPAUSE -dbatch -q locked.pdf </dev/null
What an awful link, Peacemahn!
Great post, Robert!
By the way, I have some proposition to you! Could you contact me ASAP?
I think you will see my e-mail in the comment form 🙂
Thank you thank you thank you! I’ve been working on a script using pdfkey for a few days.. turns out it was actually breaking my pdfs. I was about to go insane when I found this post.. MuPDF is PERFECT 🙂
And it installed flawlessly with homebrew 🙂
Hey, guys! If you want to use an efficient PDF Recovery tool – I can offer you a coupon code RECOVER-PROMO-15 with 15% discount. You can try this toll going to http://mac.eltima.com/pdf-password-recovery.html
Thanks a heap Rob Brewer – perfect instructions for the Terminal 🙂
Hej 🙂 I even found a easier way to do it. Download the program “Combine PDFs” for mac. The open the unlocked file in this program, merge the PDF ( even though you don’t merge anything 🙂 ) and then store the file. The merged file will be unlocked 🙂
ups sorry for the mistakes – “Then open the locked file in this program”
I just ran:
port install mupdf
then,
mupdfclean mylockedpdf.pdf myunlockedpdf.pdf
Awesome! It’s in macports.
Thank you. Very satisfying to learn that I am not the only one irritated with Amex policy. “It’s MY statement!”
MuPDF is now available via homebrew. This worked for me:
$ brew install mupdf
$ mutool clean -p thepassword input.pdf output.pdf
Pingback: Unlocking a password protected PDF file on Mac OSX/Linux | Pat's Blog
For anyone still in need of this, the MacPorts / Brew install + MuPDF tool works fine on OS X 10.9.5. THANKS for saving my bacon!
+1 for mutool clean to remove password from PDF. Worked like a charm. http://mupdf.com/
The version of BeCyPDFMetaEdit I downloaded asked for the password.
I don’t know what the AmEx password for my statements are, so having mutool was a nice way to remove the password prompt. I didn’t even have to know the password.
Thank you Robert Brewer for this post! I have a question. Do you know where I can download a ‘pdfextract’ unix executable file? If it doesn’t exist, how do you recommend I go about creating that? Thank you!