Exporting a report as a password-protected file.

Question:

How can I generate and export a PDF report protected by password, which will later be required for opening it?

Solution:

Reports are Elipse E3‘s ActiveX components called ActiveReport. They allow visualizing and printing instant values of system’s variables, as well as data stored in Databases (Alarms, Historics, Queries, and Formulas). In order to use a Report, you must first right-click Visualization — Organizer Reports, in Domain mode; then, select the option Add Report to, and pick the name of the desired project.

It’s possible to generate and export a password-protected report. To use this feature safely, configure the following properties: OwnerPassword and UserPassword. These properties belong to the report’s GetExportFilter method.

Hence, you must use a script similar to the one below, with the same properties and methods. Add this script to the event generating the report (usually, a Generate Report button’s Click event).

Example:

set report = Application.LoadReport("RelatorioAlarmes")
set exportfilter = report.GetExportFilter("PDF")
exportfilter.OwnerPassword = "Password"
exportfilter.UserPassword = "Password"
report.Export exportfilter, "C:\Relatorio1.pdf"

Notes:

  • OwnerPassword property is where you define a password for users with PDF edition permissions, including printing. This property cannot remain blank.
  • On the other hand, UserPassword property is where you define a password for users with read-only permissions. Please note that this user can’t print the file.
  • For further information on these and other properties of the export filter, check the documentation of the ActiveReports vendor, as seen below.

 

Related articles


Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 1 / 5. Count: 1

Leave a Reply

Your email address will not be published.Required fields are marked *