Acrobat User Community

Create a license agreement to control viewing of PDF files

By Ted PadovaFebruary 10, 2008

If you want to protect PDF files against unauthorized distribution and viewing, you can use any of several commercial server-based products that offer an abundance of options for securing documents and protecting them so only authorized users can open the files. However, the cost of most server-based security products makes them primarily suitable for large companies and organizations.

At the individual-user level, you don't have much opportunity to protect your content other than the built-in security features that Adobe Acrobat provides. The security features, of course, won't entirely prevent users from viewing your PDF files, since the passwords to open files can easily be distributed to unauthorized users.

You can, however, add a license agreement that requires a user to agree to the terms of your license before they view the content. A license agreement won't guard against unauthorized distribution, but you can specify terms and the agreement can be added to a PDF document viewed in all Acrobat viewers. If people violate the agreement, then tracking down the violators would be another problem. But for those who respect agreements, you can specify the terms for viewing your content.

Creating the PDF document

To begin, you need to create a PDF file with layers, which is possible with a program such as Adobe InDesign. On one layer, you add an agreement; the other layer contains the PDF content. In the authoring program, show the agreement layer and hide the content layer, then export to PDF. When the file opens in Acrobat, you should see your agreement with all the content hidden, as shown in Figure 1.

Figure 1: Adding buttons to change OCG states
See larger image


In Figure 1, I have an Agree button and a Do not Agree button. When a user clicks the Agree button, I want to show the background layer and hide the license layer. Changing the Optional Content Group (OCG) visibility is easily handled with JavaScript. In my example, the script used to change the layer visibility is as follows:

var docOCGs = this.getOCGs();
for (var index=1; index < docOCGs.length; index++){
	if(docOCGs[index].name == "LicenseAgreement") docOCGs[index].state = false;
	else docOCGs[index].state = true;
}
this.setOCGOrder( [] );

This script sets the LicenseAgreement layer to false (hidden) and changes the OCG state for the background from false to true (shown).

The Do not Agree button can be coded for an application alert message such as:

var msg ="Sorry, you can't see my document if you don't agree to the terms.";
app.alert(msg);

If a user clicks this button, a dialog box opens and reports the message contained within the quote marks.

Locking the layers

Users can bypass your agreement by opening the Navigation pane and clicking the Layers panel icon. In the Layers panel, users can change visibility to show/hide layers. In order to prevent users from bypassing your agreement by using the Layers panel, you need to do two things. First, lock the layers and secondly, secure the file.

To lock the layers, open the Layers panel and select the first layer. (LicenseAgreement in my example). From the Options drop down menu in the Layers panel, choose Layer Properties.

Click Locked in the Layer Properties as shown in Figure 2.

Figure 2

Repeat the same steps to lock the second layer.

Secure the PDF

The last step is to secure the file so a user can't unlock the layers to change the visibility.

Open the Document Properties (CTRL/Command + D) and click the Security tab. Choose Password Security from the Security Method drop down menu and the Password Security/Settings dialog box opens.

In the Permissions area. check the first checkbox shown in Figure 3 to restrict the editing. For Changes Allowed, leave the default at None. Printing options is your choice. Add a password, click OK and you will be prompted to retype your password. The security settings are applied when you save the file.

Figure 3


Caveats

Users will have to click the Agree button each time they open the file, which some may find annoying.

This procedure assumes an honor system in which you assume users are going to respect the terms of your agreement. It does not protect your file against distribution and unauthorized viewing. It certainly won't assure you payment for commercial content you intend to sell. If you have a software-piracy department equipped to track down users who violate the agreement, you could claim that one had to agree to the terms before viewing the file. However, since the OCG state won't be permanently changed, there's no way to prove that anyone actually viewed the file.

Sample File
This file contains JavaScripts and the layers are locked. The file is not secure.
Download [PDF: 1.8 MB]