Jump to content
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Sign in to follow this  
zarfishan

Java Code for Setting PDF Privileges like Copying Data, Content and An

Recommended Posts

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>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy