Copy Protected PDFs and PIL

Robert Kern robert.kern at
Fri Nov 12 21:30:06 CET 2010

On 11/12/10 2:00 PM, Brett Bowman wrote:
 > A whoops, good catch.  I meant to say gfx and swftools.  I'm using PIL to
 > modify the images once I get a PNG from swftools, and I mis-spoke.

There is nothing you can do to catch the error. swftools is not written to be 
used as a Python library, so it aborts the process when it runs into problems 
instead of raising an exception. Tough luck.

I recommend using the pyPdf library to attempt to see if the PDF is 
copy-protected first. Then use gfx to render the PDF to an image.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

More information about the Python-list mailing list