gryphon has asked for the wisdom of the Perl Monks concerning the following question:

Greetings fellow monks,

I've been searching around, but I've failed to find anything and need your help. I'm generating a whole bunch (>100) of PDF files via a Perl script. I need to use Acrobat's "Standard" PDF security option and password protect or otherwise write-lock the files.

I've looked around here and CPAN without any luck. Has anyone done this in the past? Can anyone point me in the right direction? Thanks.

-gryphon
code('Perl') || die;

Replies are listed 'Best First'.
Re: Write-locking PDFs
by abstracts (Hermit) on Jul 20, 2002 at 00:56 UTC
    Just a quick note. The PDF security options will NOT prevent people from copying/editing/printing a PDF file. Basically, it all depends on the reader software (and how savvy the user is). Here is a quote from the PDF Reference Third Edition (version 1.4 page 75):
    Note: Once the document has been opened and decrypted successfully, the viewer application has access to the entire contents of the document. There is nothing inherent in PDF encryption that enforces the document permissions specified in the encryption dictionary. It is up to the implementors of PDF viewer applications to respect the intent of the document creator by restricting user access to an encrypted PDF file according to the permissions contained in the file.
    In other words, I believe there is a patch to ghostview that will make you open and save a read-only PDF file. Also, in the same document (page 77), you'll see a list of the permissions and you can easily give yourself all permissions to a PDF file by modifying these with some editor.

    Hope this helps...

Re: Write-locking PDFs
by kvale (Monsignor) on Jul 19, 2002 at 23:51 UTC
    Text::PDF::Crypt has an encrypt() function, but I cannot comment on how standard it is.

    -Mark

Re: Write-locking PDFs
by svad (Pilgrim) on Jul 20, 2002 at 07:59 UTC
    see Re: PDF GetInfo( for an approach that can be used in your case. I mean using Win32::OLE to manage Acrobat doing things for you. Exact commands that needed for you can be found at Acrobat SDK documentation or just in Acrobat.tlb file which usually exist in a directory where Acrobat is installed.

    Also I completely agree with abstracts, it is a matter of fact that Adobe invented really imperfect security system.

    svad