encrypting an existing pdf file


I have a program that creates pdf’s using RS reports and then I email them using CURLMbs
in between RSreports creating the PDF and emailing it, I need to encrypt it with a password.

any ideas on the quickest way to do that?

You could use our DynaPDFMBS class in MBS Xojo DynaPDF Plugin to import the PDF and write it out with encryption.

an Encyrpted PDF only encrypts portions of the file, while others remain clear text (usually the section metadata, indexes etc) each text (or image) is encrypted using a method similar to a zipfile. So either the file needs to be encrypted while it is being created, or a post-production process needs to read and re-write the file.

The compression of content streams in independent of any encryption applied to the whole file.

@Christian Schmitz is there an example available on your site?

here is one:

The project file comes with the plugin download.
The pdf.EncryptPDF function is very straight forward.

PDF compression and encryption are not the same thing

Right, as I said before :slight_smile:

If CompressionLevel = 0 is used, DynaPDF will not compress content streams and you can read all the texts and drawing commands. But normally this is zlib compressed.

Encryption is on top of that for the whole file.

Basically I need the user to enter a password to be able to open the pdf and view it. I’m not fussed about how it’s achieved really as long as it can’t be reconstructed into a pdf without a password.

Thanks Christian I’ll have a look at the example.

@Christian Schmidt Seems its not available in the starter edition which it seems is what I have.

which version do I need?

I think Lite level for the encryption.