How to Remove a PDF Signature (that disallows any document changes)
PDF documents may be secured by an initial signature/certificate for disallowing any changes. This is not to be confused with “password security” or “certificate security”.
I am speaking of the kind of restrictions you will get with “Menu>File>Save as Certified Document” and then selecting “Disallow any changes to the document” (which also implies “Lock the certifying signature so that it can’t be cleared or deleted by anyone”).
This action produces a document which you cannot modify (e.g. add bookmarks or comments), and you also cannot remove the restricting signature. No PDF password remover will help you here, since there is no password!
But I found out that you can do - quite simply - disable the restrictions and render the signature removable, i.e. after these changes, you can manually delete it with Adobe Acrobat Professional:
With the Perl scripting language, this hack is applied with the following script
# Usage: perl invalidate-signing-certs.pl <in.pdf >out.pdf
binmode(STDIN);
binmode(STDOUT);
$/ = "\0";
while(<>
{
s#(/Perms<</DocMDP.*?>>)#' ' x length $1#ge;
s#(/Ff 1)(?=.*?/Lock )#' ' x length $1#ge;
s#(?<=/Lock)(.*?)(/Ff 1)#"$1" . ' ' x length $2#ge;
s#(/Lock .*?)(?=/)#' ' x length $1#ge;
print $_;
}
The next time you open the modified document with Acrobat you will still see the signature field. Just click on it with your right mouse button and from the menu popup select “Clear Signature Field”, then “Delete Signature Field”. Now safe it and everything is fine - no more restrictions. (Tip: Use “Save as” to clean up the document of any hidden signature objects.)
Note: Always make a backup of your PDF document before modifying it, since sometimes the hacks just don’t work and you end up with a document that Acrobat cannot repair.
Update August 2006: The procedure of unsigning is now available as a video (AVI, 2,4 mb). Or watch it at Youtube.com. It shows how to unsign a ebook (in PDF 1.6 format) with the batch script using Acrobat 7.0.
Update October 2006: I’ve updated the example code. The earlier version had problems due to platform-dependent handling of line endings. The current script version operates in binary mode and is tested under Window (ActiveState and Cygwin) and Mac OS X.
Download
The archive pdf-scripts.zip contains the script shown above, and some other useful scipts:
invalidate-signing-certs.pl: Invalidates all Signing Certificates, thus removing any restrictions imposed by them.bookmarks-fitpage.pl: Change Bookmark display style to “Fit Page”.bookmarks-close.pl: Close opened Bookmark Folders.bookmarks-close-1.5.pl: Close opened Bookmark Folders (for documents in PDF version 1.0-1.5, i.e. Acrobat up to 6.x)
aabiransabeel said,
June 28, 2006 @ 7:07 am
Cool, I’ve needed this option before. Thanks for the pointer.
lo said,
July 6, 2006 @ 11:32 am
Hi there, doesn`t work for me, can you provide me with a copy n paste perl code which i can execute as perl file. thx. Or lemme know which area i gotta dump within ultraedit.
Amin said,
July 15, 2006 @ 7:01 pm
Hi,can you give me a compiled software ?
I don’t think this script work…
Ron said,
July 24, 2006 @ 1:21 pm
Hi, I was wondering how I can run that piece of perl code you mentioned.
Thanks.
ARc said,
August 1, 2006 @ 5:48 am
Aren’t the pound signs comments?
ARc said,
August 1, 2006 @ 5:57 am
Agree with Amin, dont think this script works
maba said,
August 1, 2006 @ 1:02 pm
You can download a working Windows shell script (.bat) for PDF unsigning here: http://home.mnet-online.de/mbackschat/downloads/unsign_pdf.zip
yannis said,
August 10, 2006 @ 3:50 pm
It does not work for me. Porbably because my pdf is 1.6 and not 1.5. Thanks for the effort though.
zebra said,
August 12, 2006 @ 8:36 am
Do you think you could work up a way to do this on PDF 1.6s? Would be much appreciated, can’t find anything else on the net that covers this but your blog.
maba said,
August 13, 2006 @ 3:59 am
zebra, I just checked with a ebook in PDF 1.6 format; it works for me.
ratbert said,
August 15, 2006 @ 1:16 am
tried 1.5 & 1.6 still does not work even with cygwin installed in the named directory in windows, think maba made it work on a mac.
c:\Software\Cygwin\bin\perl -pe “s#(/Perms>)#’ ‘ x length $1#ge; s#(/Ff 1)(?=.*?/Lock )#’ ‘ x length $1#ge; s#(?”unsigned\%%i”
hoping maba will tell us what he/she ran it in
Mark said,
September 14, 2006 @ 10:16 pm
Maybe if you just told us the secret of what you’re changing here, we could write our own scripts? I downloaded Perl and tried out this script, but it simple made all the PDF files unopenable.
Zeeshan said,
September 19, 2006 @ 6:25 am
I have the similar problem, the files have zero lenght. Any Idea, help greatly appreciated
maba said,
September 19, 2006 @ 7:00 am
Sorry to hear about your problem with the script. Maybe you have an upload link to some of these PDFs so I can have a look at them.
BTW, I use the Perl executable from Cygwin under Windows XP. And the code presented above is actually one code line.
Name said,
September 19, 2006 @ 4:44 pm
–> perl -pe “s#(/Perms>)#’ ‘ x length $1#ge; s#(/Ff 1)(?=.*?/Lock )#’ ‘ x length $1#ge; s#(?out_unsigned.pdf
syntax error at -e line 1, near “{ .”
syntax error at -e line 1, near “;}”
Execution of -e aborted due to compilation errors.
Zeeshan said,
September 19, 2006 @ 5:27 pm
Here you go, got something for you to play with:
All I want is print this file so that I read it, cannot do it on the screem.
Its in zipped format and can be downloaded from here:
http://download.yousendit.com/9B823C0C0C64F6CF
Also it has a certificate (it came with it) have to install that to even view it.
I will really appreciate it if you can clean this up and also let me know how you did it.
thanks in advance.
Name said,
September 19, 2006 @ 5:28 pm
The above error message is returned by osx 10.4.7
BH said,
September 19, 2006 @ 7:17 pm
I do not think it is standard Perl, however, you get the same result under OSX by simply opening the .pdf file with Preview, and saving it. Zeeshan’s problem, on the other hand, it is a DRM problem that cannot be solved by simply removing the signature.
Zeeshan said,
September 20, 2006 @ 6:02 am
Hi,
Any luck with my file?
Just to let you know that when I tried your batch file, it created corrupt unsigned files which still had the same security settings.
Please help.
thanks
liufy said,
September 21, 2006 @ 6:05 am
Hi,
How about the invisible signature?
I have run the batch file, it seemed works, but I can’t find the signature logo, so I can’t clear and delete the signature fields.
thanks
maba said,
September 21, 2006 @ 2:56 pm
Zeeshan, I had a look at your PDF file. The thing is, it’s protected by a Certificate Security. My hack applies to Certification Signatures (a form of Digital Signatures for Document Authors). So, basically it’s not working for this kind of security.
Background: Acrobat 7.x Security offers the following ways to secure/restrict a PDF document:
1) Document Security Methods: a) Password security, b) Certificate security, c) APS security
2) Digital Signatures for Document Authors: Certified Signatures (aka certification signatures) for Restrictions.
My hack works for number 2) only.
maba said,
September 22, 2006 @ 11:07 am
liufy, yes, signature field can be hidden. But you can access them through the Signatures tab.
See also “Acrobat 7.X Security Feature Reference - Digital Signatures, Security Methods, and Document Security”: http://partners.adobe.com/public/developer/en/acrobat/pro_user_guide.pdf
deminy said,
September 26, 2006 @ 1:24 am
I tested the script and found it works under Cgywin on Windows (even for pdf v1.6). But …
(1). The script won’t work if running perl command installed from ActivePerl on Windows;
(2). The script won’t work if running perl command on Linux/Solaris.
Thanks for your work, maba~~
Bob said,
October 3, 2006 @ 11:07 am
Martin, could you please do the effor of checking your perl environment? Cygwin is an environment that allows for certain unix calls to work on windows too, so to compile and run open source languages and applications. By saying that your script runs on cygwin you are truly saying nothing about your perl environment. So, what type/version of perl are you using? Further, are you aware that your script does not run on other (standard) environments like linux and bsd unix? Your script really is not standard perl. So, please tell us more about it, or just tell us about the underlying operations leading to that script. Can you write the high level algorithm for your script?
Bob said,
October 4, 2006 @ 12:39 pm
Martin, you keep ignoring my note. This raises the suspicion that your script is actually a bogus.
maba said,
October 5, 2006 @ 7:08 am
Bob et al, I have updated the scripts. The problem was the different handling of line endings on the platforms; I made the mistake of operating in text mode. I have now modified the scripts to work in binary mode. It’s verified to produce the same correct output on Windows (activeState and cygwin) and Mac OS X.
Bob said,
October 5, 2006 @ 11:47 am
It works. Thanks.
Michael said,
October 6, 2006 @ 4:52 am
I already installed the Cygwin, but not working. When i run the perl script it said line 2 error. Can you please help me to see is it possible to remove the digital signature for the following file ?
URL : http://www.windy-city.com.hk/a.pdf
Many Thanks !
Michael said,
October 12, 2006 @ 10:29 am
Mabal, can you please help ?
Many Thanks !
Michael
nivarthirajesh said,
November 11, 2006 @ 9:35 pm
Can you Pls tell me how to use the Windows shell script (.bat) for PDF unsigning.
nivarthirajesh said,
November 11, 2006 @ 10:49 pm
I have found a solution.Just extract the pages.That is leave the page that has the signature.For example if there are totally 100pages and the second page has the signature field.Leave that page and extract pages 3to100 as one separate file.All done.For enquires PM at nivarthirajesh@yahoo.com
etereo said,
November 21, 2006 @ 1:18 am
This can also be achieve by re-creating the PDF file. If you have Acrobat Professional, just save as *.PS. Then double click the resulting file and finally overwrite the original PDF with this newly created one.
You can apply all desired changes or printing, etc, to this one you’ve just created.
Best regards
Johnny L. Fashkha said,
December 4, 2006 @ 10:33 pm
dear maba
i have a problem, i downloaded some ebooks, and some of them are digitally signed (teamYYePG), i want to collect these books, and i want to remove the signatures, is there any way?
thanks
John S. said,
December 13, 2006 @ 12:36 pm
On Windows with cygwin there is a problem. Enter/Return is encoded in Unix as 0A, and in Windows as 0D 0A. If unsigned file with cygwin is a bit larger, then transfer it with a FTP program to a Linux server using “ASCII” option. Then transfer it back to Windows using a “BINARY” option.
It worked for me
ita said,
February 2, 2007 @ 7:16 am
Just extract the pages you want, even if the page has the signature. The “new” pdf will not have it.
maad jordan said,
April 27, 2007 @ 3:56 pm
the conversion to *.ps is in acrobat 6.x,7.x,8.x a printing job suth reducing the images resolution so you need a raw converter not like the acrobat has..
and after texting Xpdf it was fine on only 10% of files but it losses many features like page layout..
cupcake said,
May 26, 2007 @ 11:48 am
If you do not want to install all cygwin to run Martin’s code, here is a link with only the files you need. It includes Martin’s .bat file.
http://www.divshare.com/download/740778-8aa
Thanks Martin for the code. It’s the only program that really works.
dan said,
June 9, 2007 @ 4:30 am
cupcake,
your file is dead.
Doesn’t work with cygwin on my system, return perl not a recognized command and there is no perl executable at that address.
what the heck?!
Michael said,
June 10, 2007 @ 4:34 pm
Thanks for the batch. works well. The only tricky part is installing cygwin
cupcake said,
June 13, 2007 @ 3:36 pm
Here is a new link (I hope permanent) for the cygwin files you need to have to run Martin’s code. It also includes Martin’s .bat file.
http://www.divshare.com/download/932327-549
Thanks Martin for the code.
C011IDR said,
July 1, 2007 @ 7:23 pm
The script from pdf-scripts.zip named invalidate-signing-certs.pl worked charmingly for me in an old linux box (kernel 2.4.20 = old)
with somewhat dated Perl interpreter (5.8.0 = not too bad, but still dated)
Command line:
$> ./invalidate-signing-certs.pl unprotected.pdf
thanks
C011IDR said,
July 1, 2007 @ 7:27 pm
sorry, the command line in the last post got “sanitized” and is not correct.
here, im trying to post the correct version:
$> ./invalidate-signing-certs.pl unprotected.pdf
C011IDR said,
July 1, 2007 @ 7:30 pm
$> ./invalidate-signing-certs.pl < protected.pdf > unprotected.pdf
there, mates… this should work
Sam said,
October 15, 2007 @ 3:14 am
This script works perfectly the first try. Thanks much.
Random said,
November 17, 2007 @ 2:59 pm
Dear Maba,
Thanks for your efforts but I’m not that kind of professional to use perl, can I have your personal e-mail I have one PDF file with digital signature I want to remove
Random said,
December 8, 2007 @ 2:28 pm
Please replay …
Yohanes Kurniawan said,
January 7, 2008 @ 8:22 am
Dear All,
Any pdf file size limitation for this script? I had tried but it was failed! Thanks!
Joshua Jost said,
January 22, 2008 @ 1:47 am
I just purchased an ebook and it opened up in adobe digital editions. I need to print this book and it seems there is a signature that disables printing or copying. I use an imac. I have tried to follow the above instructions: opening the terminal and pasting the script but it gives me an error saying “no such file or directory”
Please help! Thanks
Bill said,
January 31, 2008 @ 3:13 am
Thanks to nivarthirajesh for the tip. I had one of those teamYYePG files and I just unlocked it with PDF recover on a mac and then extracted pages 2-whatever and saved. I deleted the old ones and it works great. I had to do it twice, the first time I made the mistake of checking save files separately and that filled up the desktop. After trashing the files and unchecking the box, it works just as you said. I should have just left it unchecked which was the default on acrobat 7.
thaicodon said,
April 13, 2008 @ 4:57 pm
Hi, all bro!
I use Windows XP and adobe acrobat 7 professional.
I hope remove signature in this file :
http://rapidshare.com/files/105085188/Medical_and_Psychosocial_Aspects_of_Chronic_Illness_and_Disability.rar
so I use this working Windows shell script (.bat) for PDF unsigning here: http://home.mnet-online.de/mbackschat/downloads/unsign_pdf.zip
BUT it doesn’t working for me.
I really want to remove this sign.
Help me, please!
Thank you!
SPIROS said,
May 19, 2008 @ 2:05 pm
Hi
i think this will help 2!
Try to print the pdf to adobe pdf (i have pdf factor), the new pdf will have no restr..
sry for my english… be well have fun!!
去除PDF文件的数字签名及密码保护 - 碎片 said,
May 23, 2008 @ 5:19 am
[...] 或者使用Perl: http://maba.wordpress.com/2005/05/12/how-to-remove-a-pdf-certificatesignature-that-disallow-any-docu... [...]
Noel said,
June 14, 2008 @ 5:08 pm
Is it possible for you to make a small utility that can just be executed and pdf file can be imported in it. The output will be the cleared file. This will be a great help for non-techies, i.e. those who don’t know a word of scripting (like me)
Thanks in advance.
MikeH said,
June 23, 2008 @ 8:12 am
I have been wondering how to do this as well … i did not want to fool with scripts that are unkmown to me but the suggestion above to “extract” pages and resave works perfectly fine. Thanks to those who offered comments - i use Pro 8.1 at this point and the extraction idea hasn’t failed as i have cleaned up approximately 30 files this way. Thanx!