zarfishan Posted August 23, 2013 Report Share Posted August 23, 2013 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. These above methods 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 pdf1.getSecurity().setIsAnnotationsModifyingAllowed(false); //Restrict contents modification pdf1.getSecurity().setIsContentsModifyingAllowed(false); //Restrict copying the data pdf1.getSecurity().setIsCopyingAllowed(false); //Allow to print the document pdf1.getSecurity().setIsPrintingAllowed(true); //Restrict form filling pdf1.getSecurity().setIsFormFillingAllowed(false); //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 text1.getMargin().setTop(30); //Add the text paragraph to the section sec1.getParagraphs().add(text1); // Save the Pdf FileOutputStream fileOut = new FileOutputStream(new File(...)); pdf1.save(fileOut); XML Code <?xml version="1.0" encoding="utf-8" ?> <Pdf xmlns="Aspose.Pdf" IsAnnotationsModifyingAllowed="true" IsContentsModifyingAllowed="false" IsCopyingAllowed="false" IsPrintingAllowed="true" IsFormFillingAllowed="false"> <Section> <Text MarginTop="30"> <Segment>this is text content</Segment> </Text> </Section> </Pdf> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.