70002794 I wish I could set Document Restrictions when I export to a PDF file

Article 70002794
Type Wish
Product Engine
Date Added 12/3/2025 12:00:00 AM
Fixed 12.0.01 (1/26/2026 12:00:00 AM)
Submitted by fla

Summary

I wish I could set Document Restrictions when I export to a PDF file

Solution

In version 12.0.01
New enum values was added to vdDocument.FIleProperties.PDFExportProperties Properties
and new properties vdDocument.FIleProperties.OwnerPassword and vdDocument.FIleProperties.UserPassword

In the vdDocument.FIleProperties.PDFExportProperties value type of vdFileProperties.PDFExportPropertiesFlags enums the following flags were added

Allows copy or otherwise extract text and graphics from the document
AllowExtract = 16,

Allows assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if kAllowModifyOther is clear.
AllowAssemble = 32,

Allows add/modify annotations (comment), fill in interactive form fields, and, if kAllowModifyOther is also set, create or modify interactive form fields (including signature fields).
AllowAnnotateAndForm = 64,

Allows fill in existing interactive form fields (including signature fields), even if kAllowAnnotateAndForm is clear
AllowFormFilling = 128,

Allows modify the contents of the document by operations other than those controlled by flags kAllowAssemble, kAllowAnnotateAndForm, and kAllowFormFilling.
AllowModifyOther = 256,

Allows print the document to a representation from which a faithful digital copy of the PDF content could be generated.
AllowPrintAll = 512,

Allows print the document (possibly not at the highest quality level). Ignored if kAllowPrintAll is set.
AllowPrintLow = 1024,

A combination of AllowExtract | AllowAssemble | AllowAnnotateAndForm | AllowFormFilling | AllowModifyOther | AllowPrintAll | AllowPrintLow
AllowAll = AllowExtract | AllowAssemble | AllowAnnotateAndForm | AllowFormFilling | AllowModifyOther | AllowPrintAll | AllowPrintLow,

A combination of AllowExtract | AllowPrintAll
AllowDefault = AllowExtract | AllowPrintAll,

In order to set permissions you need to set an owner password (at least , user password can also be set).

vdDocument.FIleProperties.OwnerPassword:
Get/Set the owner password currently used for PDF export.
vdDocument.GetPassWord event is fired.If not implemented by the application, then a default dialog box appears to set the password.
It must be a valid not an empty password string in order PDFExportProperties Allow permissions to be applied
and all contents of the document to be encrypted and search engines cannot acces the document's metadata
Default value is empty string for no password

vdDocument.FIleProperties.UserPassword:
Get/Set the user password currently used for PDF export.
vdDocument.GetPassWord event is fired.If not implemented by the application, then a default dialog box appears to set the password.
if it is a valid not an empty password string all contents of the document to be encrypted and search engines cannot acces the document's metadata
if you want PDFExportProperties Allow permissions to be set and not require a password, set OwnerPassword to a valid not empty string and UserPassword to an empty string
if you want PDFExportProperties Allow permissions to be set and a password require, set different passwords for OwnerPassword and UserPassword and open PDF with UserPassword
if you want NO PDFExportProperties Allow permissions to be set and a password require, set empty string for OwnerPassword, not empty for UserPassword

if it is not empty and the OwnerPassword is empty string then the open of PDF require this password and the PDFExportProperties Allow permissions are not applied
If it is empty and OwnerPassword is not empty then the PDF does not require a password to open and PDFExportProperties Allow permissions applied
if it is not empty and the OwnerPassword is not empty and different than UserPassword then PDF can be open
1.with UserPassword and PDFExportProperties Allow permissions applied
2.with OwnerPassword and PDFExportProperties Allow permissions are not applied
if it is not empty and the OwnerPassword is the same as UserPassword then the open of PDF require this password and the PDFExportProperties Allow permissions are not applied
If both UserPassword and OwnerPassword no password no permissions applied to the PDF file
Default value is empty string for no password

Example:

vdDocument doc;
doc.FileProperties.PDFExportProperties = vdFileProperties.PDFExportPropertiesFlags.DrawTextAsSelected | vdFileProperties.PDFExportPropertiesFlags.AllowPrintAll;
doc.FileProperties.OwnerPassword = "owner";
doc.FileProperties.UserPassword = "user";
vdPrint printer = doc.ActiveLayOut.Printer;
printer.PrinterName = @"c:\vdfprint.pdf";
printer.SelectPaper("A4");
printer.PrintExtents();
printer.PrintScaleToFit();
printer.PrintOut();

Send comments on this topic.