[reportlab-users] PDF encryption

Dinu Gherman gherman at darwin.in-berlin.de
Sun Mar 17 16:46:37 EDT 2013


Hi,

I'm trying to create an "encrypted" PDF in which users can view all
pages without knowing any password, but perform certain operations only
when they have the user password. With the code below from the user
guide (with minimal changes) I can always even view the content only
after entering the user password:

from reportlab.lib import pdfencrypt
from reportlab.pdfgen import canvas

enc = pdfencrypt.StandardEncryption("secret",
canPrint=False, canCopy=False)
c = canvas.Canvas("hello-enc.pdf", encrypt=enc)
c.drawString(100, 100, "Hello World")
c.showPage()
c.save()

OTOH, the preview of the Python brochure does exactly that, let all
people see the content, but don't let them copy stuff e.g. without
a user password. See download on http://brochure.getpython.info

Is there a way to achieve this with reportlab.lib.pdfencrypt?

BTW, there is some space left for a ReportLab ad in the brochure...
;-)

Regards,

Dinu



More information about the reportlab-users mailing list