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)
About these ads

98 Comments »

  1. aabiransabeel said

    Cool, I’ve needed this option before. Thanks for the pointer.

  2. lo said

    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.

  3. Amin said

    Hi,can you give me a compiled software ?
    I don’t think this script work…

  4. Ron said

    Hi, I was wondering how I can run that piece of perl code you mentioned.
    Thanks.

  5. ARc said

    Aren’t the pound signs comments?

  6. ARc said

    Agree with Amin, dont think this script works

  7. maba said

    You can download a working Windows shell script (.bat) for PDF unsigning here: http://home.mnet-online.de/mbackschat/downloads/unsign_pdf.zip

  8. yannis said

    It does not work for me. Porbably because my pdf is 1.6 and not 1.5. Thanks for the effort though.

  9. zebra said

    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. :(

  10. maba said

    zebra, I just checked with a ebook in PDF 1.6 format; it works for me.

  11. ratbert said

    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

  12. Mark said

    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.

  13. Zeeshan said

    I have the similar problem, the files have zero lenght. Any Idea, help greatly appreciated

  14. maba said

    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.

  15. Name said

    –> 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.

  16. Zeeshan said

    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.

  17. Name said

    The above error message is returned by osx 10.4.7

  18. BH said

    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.

  19. Zeeshan said

    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

  20. liufy said

    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

  21. maba said

    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.

  22. maba said

    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

  23. deminy said

    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~~

  24. Bob said

    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?

  25. Bob said

    Martin, you keep ignoring my note. This raises the suspicion that your script is actually a bogus.

  26. maba said

    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.

  27. Bob said

    It works. Thanks.

  28. Michael said

    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 !

  29. Michael said

    Mabal, can you please help ?
    Many Thanks !

    Michael

  30. nivarthirajesh said

    Can you Pls tell me how to use the Windows shell script (.bat) for PDF unsigning.

  31. nivarthirajesh said

    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

  32. etereo said

    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

  33. Johnny L. Fashkha said

    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

  34. John S. said

    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 ;)

  35. ita said

    Just extract the pages you want, even if the page has the signature. The “new” pdf will not have it.

  36. maad jordan said

    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..

  37. cupcake said

    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.

  38. dan said

    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?!

  39. Michael said

    Thanks for the batch. works well. The only tricky part is installing cygwin

  40. cupcake said

    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.

    • JMM said

      It worked for me on Windows XP and Acrobat Pro 9: document is editable after running the batch. However, the signature is still here.
      To remove it permanently I had to extract the page containing the signature (then Acrobat removes the signature from the extracted page), and re-insert it in the document.

  41. C011IDR said

    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

  42. C011IDR said

    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

  43. C011IDR said

    $> ./invalidate-signing-certs.pl < protected.pdf > unprotected.pdf

    there, mates… this should work

  44. Sam said

    This script works perfectly the first try. Thanks much.

  45. Random said

    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

  46. Random said

    Please replay …

  47. Yohanes Kurniawan said

    Dear All,

    Any pdf file size limitation for this script? I had tried but it was failed! Thanks!

  48. Joshua Jost said

    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

  49. Bill said

    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.

  50. thaicodon said

    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!

  51. SPIROS said

    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!!:D

  52. [...] 或者使用Perl: http://maba.wordpress.com/2005/05/12/how-to-remove-a-pdf-certificatesignature-that-disallow-any-docu… [...]

  53. Noel said

    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.

  54. MikeH said

    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!

  55. pz said

    unsign.bat it’s use active perl to run complete ??

  56. DC said

    Can you give me the “For Dummies” version? Not tech-savvy, but I need to unsign some PDFs so I can post comments/edits in them…

  57. Fishy said

    Thanks for all your effort!

    I tried the scipts (both on an Unix box and the Windows version), both made the signature invalid. But I cannot find the signature in the document to clear it … I read that Adobe document u mentioned above and used the Signature tab and saw the signature … but still I can do nothing to it …
    Could u please help? I’ve uploaded the unsigned version :

    http://rapidshare.com/files/141405375/Essential.Neurology.4Th.Ed.pdf.html

    Thanks a lot!!

  58. Li8 said

    Thanks Maba,
    I am looking forward of a method to move certificate security, it not here, but your talent idea is very innovative!

  59. Nexus6 said

    Hi!

    Unsign Pdf for industrial printers :

    Needs iText Java Api… for read original pdf and copy it in other document!


    import java.io.FileOutputStream;
    import java.io.IOException;

    import com.lowagie.text.Document;
    import com.lowagie.text.DocumentException;
    import com.lowagie.text.Rectangle;
    import com.lowagie.text.pdf.PdfContentByte;
    import com.lowagie.text.pdf.PdfImportedPage;
    import com.lowagie.text.pdf.PdfReader;
    import com.lowagie.text.pdf.PdfWriter;

    /**
    * Class that modify some properties... (like Unsign pdf...)
    *
    * @author Nexus6@altern.org
    * @version 1.0 11/12/2006
    */
    public class PDFmodify
    {
    /**
    * Generates a PDF file
    *
    * @param args
    */
    public static void main(String[] args)
    {
    System.out.println("Usage: PDFmodify file_in file_out");

    try
    {
    // we create a reader for a certain document
    PdfReader reader = new PdfReader(args[0]);

    // we retrieve the total number of pages
    int n = reader.getNumberOfPages();
    System.out.println("There are " + n + " pages in the document.");

    // we retrieve the size of the first page
    Rectangle psize = reader.getPageSize(1);
    // float width = psize.width();
    // float height = psize.height();

    // step 1: creation of a document-object
    Document document = new Document(psize);

    try
    {
    // PdfContentByte pdfc = reader.getPageContent(1);

    // step 2:
    // we create a writer that listens to the document
    // and directs a PDF-stream to a file
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(args[1]));

    document.addKeywords("pdf");
    document.addCreator("Nexus6");
    document.addTitle("Unsign Pdf");
    document.addAuthor("Nexus6@altern.org");
    document.addSubject("Unsign Pdf");

    // document.addProducer();
    // document.addHeader("test", "coucou");

    // step 3: we open the document
    document.open();

    // step 4: we add content
    PdfContentByte cb = writer.getDirectContent();
    int i = 0;

    while (i < n)
    {
    document.newPage();
    i++;

    PdfImportedPage page = writer.getImportedPage(reader, i);
    cb.addTemplate(page, 0, 0);

    System.err.println("processed page " + i);
    }

    System.out.println("done!");

    }
    catch (DocumentException de)
    {
    System.err.println(de.getMessage());
    }
    catch (IOException ioe)
    {
    System.err.println(ioe.getMessage());
    }

    // step 5: we close the document
    document.close();

    }
    catch (Exception de)
    {
    de.printStackTrace();
    }

    }
    }

    /Nexus6

  60. MuesliMan said

    Thank you maba and cupcake + the other guys,

    you did a great job!
    finally it works (and i do not have to install all this unix shit ;-) )

  61. Luca said

    The tool just invalidates the signature. It would be a lot more helpful if if would also remove the signature.

  62. Nunya said

    I coudn’t figure out how to make it work…….

    ……….I dodn’t really spend much time on it because I just used my Acrobat 9 Pro to exstract all the pages excpet the one that had the signature on it and that got rid of it.

    Kiss mah ass, TeAM YYeP shit fer brains!!!!!!

  63. Nunya said

    Here’s the cleaned up version for the mods………

    I coudn’t figure out how to make it work…….

    ……….I didn’t really spend much time on it because I just used my Acrobat 9 Pro to extract all the pages ecxpet the one that had the signature on it and that got rid of it.

    Basically, I just created a new document from the extracted pages as the signature was on the cover.

    Take that, TeAM YYeP ……….!

  64. chetna said

    i have acrobat proffesional 7.0, using OS windows….will you help me from basic to remove digital signature…

  65. Mridul said

    Hi,

    This is an amazing script! Worked like a charm for me.

    FYI…
    I ran the script on my Fedora 10 box with perl version 5.10.0 (built for i386-linux-thread-multi)

    ~ Mridul

  66. Vedam said

    Dont break heads guys.. Print the PDF file to another pdf and remove the digital signatures and also edit the files.. no need to scripts or running any other tools..

  67. Xavier said

    Well, I must remove all digital signatures that are in a PDF using the Java language.
    Any idea how?
    Thank you very much

    • maba said

      A straightforward solution would be to take the grep-like regexp of the search&replace logic in the script and recode it in Java, using an FileInputStream (or FileReader) and the java.util.regex classes like Pattern, Matcher.
      An alternative would be the iText or the Multivaltent PDF library, however I haven’t used it for these kinds of hacks. Nexus6 has posted a solution for iText in one of the above comments!

  68. mohsen said

    hi i have a pdf that i must install a pfx file to open it
    and it’s security setting is : certificatin security
    how can i unlock it to copy pase it;s content ??
    Software\Cygwin\bin\perl –> i do not khow where can i find it and install????
    please answer soon i need it tknk you

  69. Ron said

    GREAT!!!

    tnkx

  70. rubypdf said

    iText can also do this job, but need offer certificate and the password of certificate

  71. Dave® said

    Thanks Martin! Your perl script was just I was looking for to quickly change a lot of bookmarks to Inherit Zoom.

  72. rubypdf said

    maybe this one is better

    PdfReader reader=new PdfReader(“F:\\soft\\rapidshare\\abcd.pdf”);
    PdfStamper stamper=new PdfStamper(reader,new FileOutputStream(“f:\\oooo.pdf”));

    reader.removeFields();
    AcroFields fields=reader.getAcroFields();

    /* System.out.println(fields.getSignatureDictionary(“Signature2″));
    PdfDictionary dic = (PdfDictionary)PdfReader.getPdfObject(reader.getCatalog().get(PdfName.SUBFILTER));
    if(dic!=null)
    {
    System.out.println(dic);
    //reader.getCatalog().remove(PdfName.PUBSEC);

    }*/
    stamper.close();
    reader.close();

  73. ayhan said

    hi guys. i bought an ebook, and download it. When i click on pdf, it is asking “this document requires DRM features supported by Adobe Digital Editions. Would you like to open it?”
    and print option is disabled. It is using adobe digital editions 1.7.

    Do you think it can be converted to print option enabled? and above this methods, are they working for ade 1.7?
    thanks

  74. Eric von Bayer said

    Your script couldn’t unlock the signature from a PDF I tried recently. I added this line and it now works. Very handy util.

    s#( obj<<)([^>\rendobj)#$1 . (‘ ‘ x length $2) . $3#ge;

  75. Harish said

    Awesome.. thanks a lot.

  76. Jon said

    I freaking want to kill myself!!!!!!!!

    i have a pdf file which I still haven’t been able to unsign. even worse, i can’t save it as .ps and i can’t delete or extract relevant pages.

    someone please help :(

  77. kode said

    Are you available? You don’t have any contact information that could result in a whois… please try to e-mail me soon as I have an idea that will drastically improve your script. Or just put it up on github and if some people sign up for the project I’ll e-mail the idea to them.

    Saved as PDF script idea.

    • kode said

      Also, the added line… maybe this needs a github!!! Or a google code page!

  78. BQ said

    Using Perl -wc I determined the current version of Perl apparently doesn’t want me to use “length” as a variable, so I changed it to “length1″. Even after that change, the script doesn’t appear to be working on a Fast Web View 1.6 document.

    I’ll be grateful for suggestions!

  79. Mark said

    OK, I’m lame. I got “syntax error line 6, 7, 8, 9 near x length. ulp.

  80. Cyrus said

    Dear MABA,
    I’m a complete newbie here. I have acrobat X pro and a signed pdf which I need to remove.
    please provide me a step-by-step guide..

    thanx

    • Tim said

      “please provide me a step-by-step guide…”

      This is why you will always be a newbie. Google it. Learn it. nobody is going to spoon feed you.

  81. This particular blog is an excellent read, thanks for the details.

  82. ProFan said

    I read the posts, but decided to try something else first and it work. Before running the script try printing pdf first. Result is new pdf document with no signature.

  83. degarmo said

    Maba
    Do you have or know of a hack that will remove the Certificate Security?

  84. Bishop said

    You don’t need a hack…all you need to do is this!
    1. Open the document or reopen it to get the signature panal
    2. Right click the signature and then select go to signature field
    3. Now just print the document to another PDF without the page with the signature.
    4. BAM!! You can edit the document!

  85. I tried this perl script and since perl is only installed on one of my webservers, i scp the file to it along with the script. I chmod it to 755 so its executable so i ran ./invalidate-signing-certs.pl protected.pdf unprotected.pdf

    However it just shows a bunch of jumbled stuff on the terminal output then that says PuTTYPuTTYPuTTY over and over and over again until I CTRL+C to kill it. How can I run this?

  86. lorschy said

    damn guys, don’t you ever read anything ?

    you need to use the redirect operators for in & output file …

    ./invalidate-signing-certs.pl OUTFILE

  87. yogesh said

    i have a file can u remove signature so that i can take printouts

  88. Rouge said

    I’ve been reading all your comments, and it made my head spin to those “scripts” whatsoever. I have the same problem and I just solved it my own way (trust me). Here’s a simple solution:
    1. Open the PDF file.
    2. Print, on printer dialouge box in Printer Name, select PDF Complete
    3. OK and Save the file.
    4. Open the PDF you have just saved, as as you can see there is a “PDF Complete logo”at the corner. To Delete go to Tools, Advance Editing, TouchUp Object tool, and delete all the logo.
    5. As you can see there still a black boarders, to delete go to Tools, Advance Editing, select Button, click the border and delete it. That’s it!

    Hope I could help.

  89. Nisha said

    Hi,
    Anyone can tell me how to use the text file “bookmarks-fitpage.pl”.

    Thanks

RSS feed for comments on this post · TrackBack URI

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: