This technical tip shows how to allow or disallow privileges on PDF document using Aspose.Pdf for Java. Aspose.Pdf continues to provide more security features to protect the use of your valuable information in PDF documents. Using Aspose.Pdf, developers can set several privileges on the PDF documents to control their use. All the privileges related properties are of Boolean types and can be controlled by setting to true or false. The methods used allow developers to restrict or allow annotations modification, contents modification, copying the content, degraded printing, document assembling, form filling, printing the pages and screen readers.

Set Privileges on the PDF Documents

//Instantiate Pdf object by calling its empty constructor
Pdf pdf1 = new Pdf();

//Assign a security instance to Pdf object
pdf1.setSecurity( new Security() );

//Restrict annotation modification

//Restrict contents modification

//Restrict copying the data

//Allow to print the document

//Restrict form filling

//Add a section in the Pdf
Section sec1 = pdf1.getSections().add();

//Create a text paragraph
Text text1 = new Text(sec1,"this is text content");

//Set the top maring of text paragraph to 30

//Add the text paragraph to the section

// Save the Pdf
FileOutputStreamfileOut = new FileOutputStream(new File(...));;

XML Code

<?xml version="1.0" encoding="utf-8" ?>
<Pdfxmlns="Aspose.Pdf" IsAnnotationsModifyingAllowed="true"
IsContentsModifyingAllowed="false" IsCopyingAllowed="false"
IsPrintingAllowed="true" IsFormFillingAllowed="false">
<Text MarginTop="30">
<Segment>this is text content</Segment>