To add All-About-PDF’s Royalty-Free DRM engine into your .NET Framework project, start by adding the AllAboutPDF.DRM library reference from the NuGet repository.

PM> Install-Package AllAboutPDF.DRM -Version 1.0.0

Once it has been added to your project, refer to this document to learn more about the library’s methods and properties.

You may also download a sample project from here.


DRMController Class

Provides the methods for protecting PDF documents with All-About-PDF’s DRM library.

public class DRMController(string LicenseKey)

The LicenseKey will be sent to you once you have purchased the Developer license. For trial usage, use the license key TRIAL-LICENSE-KEY.

Methods

public Tuple<bool,string> ProtectPDF(string InputPDF, PayLoadModel DRMSettings, string OutputFile)

Adds DRM protection to the PDF file specified and is saved to a PDFe file. The methods returns a Tuple of boolean and string indicating if the method was successful and any error messages that occurred.

Method Parameters

string InputPDF: the path to the PDF file that you would like protected

PayLoadModel DRMSettings: the DRM settings that will be applied to the PDF document

string OutputFile: the output file that will be the result of DRM protection. The file must have the extension of “pdfe”.


PayLoadModel Class

Holds the DRM settings that will be applied to the PDF document.

public class PayLoadModel()

Properties

public string ExpiryMessage { get; set; } : the message that will be shown when an expired document is opened.

public DateTime ExpiryDate { get; set; } : the date and time when the document will expire.

public bool UseInternetTime { get; set; } : specifies if the PDFe Reader will validate the date and time using cloud service instead of system clock.

public bool AllowPrinting { get; set; } : specifies if the user will be allowed to print the PDFe document.

public bool AllowSaveAs { get; set; } : specifies if the user can save the PDF as an unprotected file.

public bool ExpireDaysAfterFirstOpen { get; set; }: specifies if, instead of a static expiry date, the PDF document will expire so many days after being opened

public int ExpireDaysAfterOpeningNum { get; set; } : specifies how many days after being first opened the PDF will expire.

public bool HasOpenPassword { get; set; } : specifies if the PDFe document has an open password.

public string OpenPassword { get; set; } : the password to open the PDFe file

public bool CloudValidation { get; set; } : specifies if the entire PayLoadModel should be validated against All-About-PDF’s cloud to bypass local tampering

public ExtendedDRMProps ExtendedProp { get; set; } : extended DRM properties (see below)


ExtendedDRMProps Class

Holds other advanced DRM settings for the PDF document

public class ExtendedDRMProps()

Properties

public bool IsGeolocked { get; set; } : specifies if the PDFe document should be locked to one or more countries

public List<string> AllowedCountryCodes { get; set; } : a list of one or more countries where the PDFe document can be opened. The list should be specified using ISO 3166 country codes

public bool IsDomainLocked { get; set; } : specifies if the PDFe document should be locked to one or more IP addresses

public List<string> AllowedDomains { get; set; } : a list of one or more IP address where the PDFe document can be opened.

public bool LimitNumberOfPrintsAllowed { get; set; } : specifies if printing should be limited

public int MaxPrintsAllowed { get; set; } : the maximum number of times that the PDF can be printed if printing is allowed.

public bool IsEmailLocked { get; set; } : specifies if the PDFe document should be locked to one or more email addresses.

public List<string> AllowedEmailAddresses { get; set; } : a list of one or more email addresses that can view the PDFe document.