Archive for May, 2005

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)

Comments (106)