- 26 Feb 2025
- 1 Minute to read
- PDF
PDF security
- Updated on 26 Feb 2025
- 1 Minute to read
- PDF
On the PDF chain Element, select the Security tab and expand Permissions
To change the values of the Permissions, click on the drop down arrow and set the value to either True of False.
To lock the PDF permissions from being changed using a 3rd party tool, you can set the OwnerPassword. This setting will allow anyone to view the PDF yet still lock the permissions in place should a user try and edit the PDF.
To password protect the PDF, you can set a UserPassword, this can be done by using dynamic script to set the value of the password to a data fields value.
Below is a sample of the script that utilises a few different methods of setting the password dynamically:
if (elementName == "CHAINID") // Check the ID of the convert to PDF element
{
AIS.DocFusion.ProcessingElements.RTFConvertor.PDFConvertorElementConfiguration cfg;
// Need to add reference to AIS.DocFusion.ProcessingElements.RTFConvertor
cfg = (AIS.DocFusion.ProcessingElements.RTFConvertor.PDFConvertorElementConfiguration) elementConfiguration;
// Method 1 : Use Environment Variable (Declared in DocBench)
// NB: Use your environment business unit tenancy GUID
//string epVal;
//if (base.CachedEnvironmentVariableContainer.GetEnvironmentVariableValue(Guid.Empty, "PdfPassword", out epVal))
//{
// cfg.ApplyPDFSecurity = true;
// cfg.UserPassword = epVal;
//}
//
// Method 2 : Use dynamic object – This sample assumes your DataModel has a rootItem.FullName in either the JSON, or XML that you sent
//dynamic obj = base.AISxRequestDataBinding as dynamic;
//cfg.Properties.Author = obj.FullName;
//
// Method 3 - Use Dictionary from dynamic object
// Dictionary<string, object> itemData = (Dictionary<string, object>) (base.AISxRequestDataBinding as dynamic);
// cfg.Properties.Title = itemData["Topic"] as string;
// Method 4 : Use XPATH or JSONP
// string rawData = base.AISxRequestData; // Will return input data
// insert code to extract value
// Method 5 : Use Parameteres
//string theUserValue = base.Parameters["ParameterName"];
// Set the instance value on the chain element
cfg.ApplyPDFSecurity = true;
cfg.UserPassword = theUserValue;
}
Should you use a Static Owner/User Password, please ensure that you set the permissions on the chain to the relevant users as anyone with access to the chain will be able to edit/view the Owner Password