com.cete.dynamicpdf
Class StandardSecurity



Example : The following example will set the standard security of the document so that the anyone who logs in with the user password will not be able to print, edit or copy the document or its contents.
   import com.cete.dynamicpdf.*;
   import com.cete.dynamicpdf.pageelements.*;
 
   public class MyClass {
     public static void main(String args[]) {
        // Create a PDF Document
        Document document = new Document();
 
        // Create a Page and add it to the document
        Page page = new Page();
        document.getPages().add( page );
 
        // Create a standard security object
        StandardSecurity security = new StandardSecurity( "owner", "user" );
 
        // Set the permissions on that security object
        security.setAllowPrint( false );
        security.setAllowCopy( false );
        security.setAllowEdit( false );
 
        // Add the security object to the document
        document.setSecurity( security );
 
        // Create and display a label as a reference
        String text = "This document has been encrypted with 40 bit encryption.";
        page.getElements().add( new Label( text, 50, 50, 400, 100, Font.getHelvetica(), 18 ) );
 
        // Save the PDF
        document.draw( "[physicalpath]/MyDocument.pdf" );
     }
    }