DEMKO.CA

PDF Hacking

Introduction

"Encrypted" PDFs produce postscript files that have little traps in them making them only printable, and not re-distillable. This is annoying.

To de-trap these .ps files and make them distillable again, do the following:

Searching hints

All the blocks have something like this:

% Removing the following BLAH lines is illegal, subject to the Digital Copyright Act of 1998.

Also note, the hexdecimal contents might not match exactly.

Type 1 Blocks

Find all:

mark currentfile eexec
54dc5232e897cbaaa7584b7da7c23a6c59e7451851159cdbf40334cc2600
30036a856fabb196b3ddab71514d79106c969797b119ae4379c5ac9b7318
33471fc81a8e4b87bac59f7003cddaebea2a741c4e80818b4b136660994b
18a85d6b60e3c6b57cc0815fe834bc82704ac2caf0b6e228ce1b2218c8c7
67e87aef6db14cd38dda844c855b4e9c46d510cab8fdaa521d67cbb83ee1
af966cc79653b9aca2a5f91f908bbd3f06ecc0c940097ec77e210e6184dc
2f5777aacfc6907d43f1edb490a2a89c9af5b90ff126c0c3c5da9ae99f59
d47040be1c0336205bf3c6169b1b01cd78f922ec384cd0fcab955c0c20de
000000000000000000000000000000000000000000000000000000000000
cleartomark

And delete the blocks.

Type 2 Blocks

Find all:

currentfile eexec
6ebb4949d640ad13b78a1bb8e40ddda64d5017a356a3e054d4e1051a6bef
a74a655154d80bc1e572a832e3a113270ca21bc7f22bb0d921288f9fdb1b
65980fc8986fd90f583455f2d67b7cddc1be414b1a01e4209d1c1e5a5ece
e16abdf9dc96d5b3286d08b880b27069f230eb17c6f5ffc4c814730800a2
858b048265b04bc3145f63150f12ba7b03c273e367942289c4c00caeea46
233185aa941a68a65553e43f51aef1632b74d2d237320932e572ba2c9a0e
c068f285c48e9bdb0d645fbd86fb46c8cb99f2bb0d2d4db8b8d8f6be99f2
3f38cd9d077436b46d5e5048bcf0f4eb0c79c842bb074e92be0717220322
6641d3dbc7cda5576ac556416da0051814c2705e

And REPLACE each block with:

PDFVars begin PDF begin PDFVars/InitAll get

Research Notes

Type 1 blocks decrypt (via the eexect command) to:

/currentdistillerparams where { pop /pdfmark where
{pop (This PostScript file was created from an encrypted PDF file.\n)
print
(Redistilling encrypted PDF is not permitted.\n) print
userdict /quit get exec }if} if
currentfile closefile

(fully enclosed, hense deletable outright)

Reference, see Q2.6 in the comp.text.pdf faq

Type 2 blocks decrypt to:

/currentdistillerparams where { pop /pdfmark where
{ pop (The owner of this file does not permit its conversion\
 to PDF.)print quit}if }if
end PDFVars begin PDF begin PDFVars/InitAll get
currentfile closefile

(yet you need the pdfvar stuff, so that needs to be spliced out)

Reference: ghostscript

A handy postscript reference

the end -- alexd -- Oct 13, 2006 -- version 1.0