These files are forwarded as received. No responsibility whatsoever
is assumed for their utility,
accuracy, or legality.
Subject: Encrypted PDFs
Date: Mon, 03 Mar 1997 11:10:59 -0800
From: icijgap1@ix.netcom.com
Check out the latest versions of ghostscript and pagedraw. The DOS version of ghostscript now comes with ps2pdf, and the beta 32 bit version of pagedraw can export to PDF.
Rick Holbert rholbert@juno.com
http://www.ozemail.com.au/~geoffk/pdfencrypt/
Encrypted PDFs
When you give a PDF document an owner password, Adobe Acrobat encrypts it so that you can't just remove the password from the file. Unfortunately, not only did Adobe not explain how the encryption works, but because of stupid US regulations about exporting cryptographic software, the encryption cannot be added into programs like GhostScript which are distributed with source code from the US.
This web page, however, is not in the US, so I can provide here the modifications necessary to view encrypted PDFs with GhostScript.
GhostScript versions 4.01 and earlier
To allow versions of GhostScript from 3.33 through 4.01 to read encrypted PDFs, you need to download the appropriate patch from the list below, place it in the same directory as the files pdf_base.ps and pdf_main.ps, and pipe them into patch -l. If you don't have `patch' on your machine, you can probably find a version at your friendly GNU archive.
There are patches for versions:
The last of these patches is quite a bit better than patches for earlier versions.
It is likely that these patches will not work if GhostScript is compiled with 64-bit integers.
GhostScript versions 4.02 and later
For these versions, things became somewhat simpler. All you need to do is replace the file called pdf_sec.ps with the version provided below, as described in the documentation.
This file is version 1.01, which has been revised to work on interpreters with 64-bit integers.
Usage information
If GhostScript reports ****This file has a user password set., you can specify a password by setting PDFPassword to either the user or owner password of the PDF file. On the command line, you might say gs -sPDFPassword=apassword somefile.pdf. Inside GhostScript, you can say /PDFPassword (apassword) def. You can also put this in a file generated with pdf2dsc; put it just after the line that says %%BeginProlog.
Technical Details
If you're interested in how the patch works, you should look at version 1.2 of the PDF reference manual (available at Adobe's Web site). My patches predate this description, but they seem to conform to it exactly.
RC4-compatible
and
MD5
PostScript
Source for an RC4-compatible algorithm implemented in PostScript. Source for MD5 implemented in PostScript.
If you have your browser set to automatically run PostScript files with (say) Ghostview, you'll find doing that is not very interesting, as they don't make any marks on the page; they just run some self-tests.
Turns out that gsview can now print to a pdf file. This makes converting postscript documents to pdf a snap. I converted a 3 Meg paper to pdf with only one small snag. It turns out that the author encluded several bitmap screen dumps in the postscript source document that displayed properly under gsview, but couldn't be converted into pdf.
Also, there's a company called Zeon that has free demo copies of their pdf construction tools and a free reader. Their url is http://www.zeon.com.tw
My bandwidth here at work is very low, so I haven't ftp'ed the files yet.
Hope this is of interest
Rick Holbert rholbert@juno.com