In this post, we will explore how we can password protect PDF output generated by a Oracle XML Publisher Report.

Check out my earlier posts on XML Publisher for more details on XML Data Template, RTF Template, Triggers etc. Now lets take a look at what we are planning to build today. You can download all the sample files here.

Output
The report output has Supplier and Invoice Details. You can refer to the Output below or you can download the same here.

pdf_output_file

XML Data Template File
The XML Data Template file has the SQL query and parameter details. The file looks as shown in the image below. You can also download the Data Template File from here.

data_template_file

Output XML File
The Output XML File has all the data elements that are required to generate the final output in PDF format. Check out the same in the below image or download it from here.

xml_output_file

Static Password

You can set a static password for the output. This means, the password will remain the same for the report output. You can set this property in the RTF Template itself. Lets see how we can achieve the same.

Open RTF Template and Click on File. You will get a screen as shown below:

rtf_template_option

Make sure you are on the Info Tab and then click on Properties. This will give you a list of options. You will have to select “Advanced Properties“.

rtf_template_advanced_options

On the next screen, we need to define the below custom properties that will help us to password protect PDF outputs.

[table id=2 /]

rtf_template_custom_properties

Let us enter the details for PDF Security property. You can find the details in the table listed above. Refer to the below screen shot for more details.

rtf_template_pdf_security

Once you have entered all the details, click on “Add“. In the same way, enter the details for the PDF Password Property. The property name should start with “xdo”.

Once you have completed entering the details of both the properties, save the RTF Template and you are all set to test the output. Since we have given a static password, enter the value 123456 when prompted for the password.

Dynamic Password

The best way to secure the output file is to generate a dynamic password for the output file. We can achieve this by using a value from the xml data element.

For Eg, you want to email the invoice details to the suppliers and also secure the file with a password. Since you will be sending the file to different suppliers, it does not make sense to keep the same password for all the files. Instead, you can use the supplier number as a password. This way the password will be different for the files send to the different suppliers.

To get the supplier number, we can use the value from /INVOICEDATA/LIST_G_SUPPLIER/G_SUPPLIER/SUPPLIER_NUMBER.
Check the output XML Data file to confirm the same.

Set the “xdo-pdf-security” to true. This is the same as discussed in the earlier section on how to set a static password.

For “xdo-pdf-open-password” property, the value field should have the following {/INVOICEDATA/LIST_G_SUPPLIER/G_SUPPLIER/SUPPLIER_NUMBER}. Make sure that to include the “{}”.

rtf_template_pdd_pwd_xml

Save your RTF file and you are all set to test the solution. The XML Data file that I have included has supplier number as “10031“. So you can use the same when prompted for a password.

You can use the same in conjunction with XML Bursting. This will allow you to send files as attachment and also password protect PDF output.

Let me know if you have questions. As always, let me know your suggestions and feedback.

8 Responses

  1. I have tried to add dynamic password by follow above steps but it is not asking any password .. what could be the issue.

  2. Hi,Thank you for information,My doubt is how to generate dynamic password with combination of
    first 4 letters of supplier name that too in upper case and supplier number or part first 3 digits of supplier number.
    can i use cancatination and substring here

Leave a Reply

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