How to create password protected PDF?

Dear All,

For one of our requirement, we need to create a password protected PDF. So,

[ul]1. How to create password protected PDF in Ignition?
2. If not possible in Ignition, Can we use any other third party library or sample Jython/Python code? if yes, please suggest us.[/ul]

Thank you

PDFs can absolutely be password protected in Ignition. There’s so many things that can be done in Ignition that the company behind Ignition, Inductive Automation, has a motto, “Dream it, Do it”.

A PDF can be password protected in Ignition by displaying a PDF in Ignition using the PDF Viewer component. Then cover the component with a different component, such as a rectangle or label - therefore preventing access to the PDF. Provide a text field for a user to enter a password. When the correct password is provided hide the label or rectangle and so give access to the PDF.

A password could be stored in a memory tag or in a database or in a custom property on an object.

Password protecting a PDF is easy to implement in Ignition.

Best,

To add onto Nick’s post.

If you have pdf stored as bytes in a database, you can have a column for password which is fed to when retrieving the pdf for display.

There really are numerous ways to implement this type of functionality.

I think what he means is that he wants the actual pdf that is saved to be password protected, Not just password protected in the Ignition Client Interface.

Oh okay. Similarly slap an invisible label component that covers the entire Report Viewer. This will capture the right-click that is needed to print the report.

Then have a text field to receive the password. When the right password is input make the invisible table component disappear. Or use the print method on the report viewer object to print the report: report.print() There a lot of different ways this can work.

Best,

[quote=“nmudge”]Oh okay. Similarly slap an invisible label component that covers the entire Report Viewer. This will capture the right-click that is needed to print the report.

Then have a text field to receive the password. When the right password is input make the invisible table component disappear. Or use the print method on the report viewer object to print the report: report.print() There a lot of different ways this can work.

Best,[/quote]

I think he means a password-protected PDF file. Forget Ignition exists for a second and just think a PDF that requires a password to open.

All speculation at this point, we need more info from the OP :slight_smile:

Thank you all for your replies. Let us make our question clear.

Lets say, we generated a dynamic report using Report Viewer component and user saved the report as PDF to his/her system. We want the saved PDF to be password protected so that he/she cannot open the report (using Adobe Reader or Foxit Reader etc.) untill they enter valid password.

Hope, our question is clear now.

Thank you

Hi All.

It has been long time. Does anybody have inputs on our question?

Hi Sasi,

Ignition cannot do what you want natively. However, you can add such a password with free tools like pdftk aka the “PDF toolkit”. Or if the client is Windows, you can use products like “PDF Creator” to protect your PDF after printing to a virtual printer.

Hope this helps.

Phil

A followup:

If you absolutely must make sure the PDF is protected on disk, call “pdftk” as a subprocess and send the bytesPDF contents to the subprocess as stdin. The command line for pdftk would need the settings to read from stdin, apply the desired password, then write to a target filename. Something like

pdftk - output myfilepath user_pw mypassword allow printing copycontents screenreaders

Substitute “myfilepath” and “mypassword”; the rest is verbatim.
This approach is not entirely secure, as the password will show in the command line to other logged in users via process monitoring tools.

Thanks Phil. Let us try for workaround as you mentioned.

Hello Kevin,

Now in 2024, do you think something more robust could be done in ignition?

I need to send files with sensitive information by email, and the truth is that the reporting module of ignition falls short in this...

Thanks

The most robust approach is to only send links in email, where the link requires authentication. A dedicated Perspective project or a WebDev API are the approaches I would recommend.