http://qs1969.pair.com?node_id=412254

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

I have a PDF document that I'm offering as an electronic download. The publisher want's password protect the document.

Is there a way in perl to add password protection to a PDF doc?

Thanks

  • Comment on Insert Password Protection into PDF Doc's

Replies are listed 'Best First'.
Re: Insert Password Protection into PDF Doc's
by dragonchild (Archbishop) on Dec 03, 2004 at 20:08 UTC
    Generally, there aren't any good utilities to edit PDFs in Perl. Create, yes. Read, yes. Edit ... not so much.

    Additionally, you are aware that password protection is an advisory thing in the PDF format. Adobe respects it, but there are literally dozens of utilities that you can google for that will read the PDF document and ignore the password.

    If the publisher is demanding this, then ask them to provide a password-protected version. That way, if anyone cracks it, it's their problem, not yours. There is a legal liability issue. If you password-protect it and it's cracked, they can claim you screwed up. If, however, you're just the delivery vehicle, you are immune to liability for that issue.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      Is it still true that passwords are merely advisory? I have difficulty finding information for this after Acrobat 5. . .
        All versions of Acrobat honor all passwords contained in a PDF. But, the PDF format itself treats passwords as advisory. So, it's a format issue, which means that any given client may choose to honor the passwords ... or not.

        Being right, does not endow the right to be rude; politeness costs nothing.
        Being unknowing, is not the same as being stupid.
        Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
        Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: Insert Password Protection into PDF Doc's
by StrebenMönch (Beadle) on Dec 03, 2004 at 20:38 UTC
    Would it be feasible for you to create a small site that requires the user to log in before you render/deliver the pdf to them?

    This would be a more complex way of doing it than what dragonchild suggested, but thought I would offer an alternate idea. =)
    S t r e b e n M ö n c h
Re: Insert Password Protection into PDF Doc's
by l3nz (Friar) on Dec 03, 2004 at 20:10 UTC
    I frankly don't know much about PDF, but one thing that comes to my mind is that if you run under Win32 and you have some program doing the password protection, you can usually script it from Perl using either OLE capabilities (for big, well written programs) or the canonical system() call.