Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Insert Password Protection into PDF Doc's

by awohld (Hermit)
on Dec 03, 2004 at 20:03 UTC ( #412254=perlquestion: print w/ replies, xml ) Need Help??
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
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 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.
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://412254]
Approved by zejames
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (21)
As of 2014-09-23 14:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (223 votes), past polls