DRM using Command Line Interface

To apply DRM to PDF file(s) from the command line, you first need to create a JSON file that holds all the parameters. The structure of the JSON file is as follows:

{ "FileToProcess": "C:\\Demo Files\\*.pdf", "SetPDFToExpire": true, "ExpireOnDate": true, "ExpireAfterXdays": false, "ExpiryDate": "2021-09-10", "ExpiryTime": "03:00", "ExpiryMessage": "The PDF has expired. Please contact the author", "Xdays": 0, "LockPDFToCountries": true, "AllowedCountries": { "GB": "United Kingdom", "US": "United States" }, "LockToIPAddresses": true, "AllowedIPAddresses": ["136.57.204.243", "127.0.0.1"], "AllowPrinting": true, "MaximumNumberOfPrints": 5, "PDFUserPassword": "", "PDFOwnerPassword": "", "UseCloudValidation": false, "LockToXDevices": false, "MaxDevices": -1, "OutputFolder": "C:\\Demo Files\\Results" }
Parameter Description
FileToProcess The PDF file to process. This can include wild cards to process multiple files e.g. *.pdf to select all files in a folder with the PDF extension
SetPDFToExpire true or false if you would like DRM to set an expiry date
ExpireOnDate true or false if you would like to specify a date when the PDF expires. Can only be set to true if ExpireAfterXdays is set to false
ExpireAfterXdays true or false if you would like the PDF to expire after so many days after being opened. Can only be set to true if ExpireOnDate is set to false
ExpiryDate The expiry date in the format yyyy-MM-dd e.g. 2021-12-31 for 31st December 2021.
You can also use a date that is dynamic by using the value .currentdate(n) where n is the number of days to adjust the current date by.
For example, to always have the expiry date 30 days from the date the file is processed, use .currentdate(30)
ExpiryTime The expiry time in the format HH:mm e.g. 15:30 for half-past three in the afternoon.
You can use a dynamic time using the .currenttime(n) where n is the number of hours to adjust the current time by.
ExpiryMessage The message that will be displayed when the document expires. This can be plain text or HTML
Xdays If ExpireAfterXdays is true, how many days after first opening the file that the PDF will expire
LockPDFToCountries true or false if the PDF should be only be openable in certain countries
AllowedCountries A dictionary collection of the countries where the PDF can be viewed. The values should in the form CountryCode: CountryName
LockToIPAddresses true or false if the PDF should be only be openable in certain IP addresses
AllowedIPAddresses An array of IP addresses where the document can be viewed
AllowPrinting true or false if the document can be printed
MaximumNumberOfPrints If printing is allowed, the maximum number of times that the file can be printed
PDFUserPassword (Optional) PDF user password
PDFOwnerPassword (Optional) PDF owner password
UseCloudValidation true or false if the date should be validated using internet time
LockToXDevices Coming soon
MaxDevices Coming soon
OutputFolder (Optional) folder location where the resulting files should be placed. If left blank, the resulting files will be placed in the same folder as the original files

You can create this file to get you started by configuring the options in All-About-PDF and saving the settings to a file (see image below)

Saving DRM Settings to File

Once the file is saved, you can then use it at the command line as follows:

%programfiles%\All-About-PDF\all-about-pdf.exe /applydrmwjsonfile {c:\users\johndoe\desktop\drmsettings.json}