Click or drag to resize

Security Options

With the security options you can allow or deny printing, editing, copying and filling form fields, and set a user password and an owner password. When you set a user password the PDF document is encrypted and the PDF viewer asks for that password to open it. The owner password is required to change the permissions of the document. When only the user password is set, it is also used as the owner password, and a reader who opens the document with it has every permission.

The PdfSecurityOptions property of the PdfConverter object sets the security options of the generated PDF document:

PdfConverter pdfConverter = new PdfConverter();

pdfConverter.PdfSecurityOptions.CanCopyContent = false;
pdfConverter.PdfSecurityOptions.CanEditContent = false;
pdfConverter.PdfSecurityOptions.CanFillFormFields = true;
pdfConverter.PdfSecurityOptions.CanPrint = true;
pdfConverter.PdfSecurityOptions.CanEditAnnotations = false;
pdfConverter.PdfSecurityOptions.CanAssembleDocument = false;

pdfConverter.PdfSecurityOptions.KeySize = EncryptionKeySize.EncryptKey256Bit;
pdfConverter.PdfSecurityOptions.UserPassword = "user-password";
pdfConverter.PdfSecurityOptions.OwnerPassword = "owner-password";

pdfConverter.SavePdfFromUrlToFile("https://www.example.com", "protected.pdf");
Encryption

KeySize chooses the encryption: EncryptKey128Bit (the default) encrypts with AES-128, EncryptKey256Bit with AES-256, readable by Adobe Reader X and later and by every current PDF reader, and EncryptKey40Bit with 40 bit RC4, the weakest, for very old readers only. EncryptMetadata set to false leaves the XMP metadata of the document readable - by a search index, for example - while everything else stays encrypted.

A PDF/A or PDF/X document cannot be encrypted: those standards forbid it (see PDF Standards). To protect, sign or remove the protection of existing PDF files, use the PDF security tool described in Passwords and Encryption.

See Also