[]
        
(Showing Draft Content)

PdfSecurityOptions

Class PdfSecurityOptions

java.lang.Object
com.grapecity.documents.excel.PdfSecurityOptions

public class PdfSecurityOptions extends Object
Represents PDF security settings.

Use this class to specify passwords and permissions for a PDF document, such as whether the document can be printed, modified, annotated, or have its content extracted. These settings can be applied through PdfSaveOptions.setSecurityOptions(PdfSecurityOptions) when saving a workbook to PDF.

Use high-entropy, unique passwords from secure configuration or a key management service. Do not hard-code PDF passwords in application code.


 PdfSecurityOptions securityOptions = new PdfSecurityOptions();
 securityOptions.setUserPassword(getPdfUserPassword());
 securityOptions.setOwnerPassword(getPdfOwnerPassword());
 securityOptions.setPrintPermission(false);
 securityOptions.setExtractContentPermission(false);
 PdfSaveOptions options = new PdfSaveOptions();
 options.setSecurityOptions(securityOptions);
 workbook.save(new ByteArrayOutputStream(), options);
 
  • Constructor Details

    • PdfSecurityOptions

      public PdfSecurityOptions()
  • Method Details

    • getUserPassword

      public String getUserPassword()
      Gets the user password of the PDF document.

      This password is used to open the exported PDF document when a user password has been specified through setUserPassword(String).

      Use a high-entropy, unique password from secure configuration or a key management service. Do not hard-code this value in application code.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       String configuredUserPassword = getPdfUserPassword();
       options.setUserPassword(configuredUserPassword);
       String userPassword = options.getUserPassword();
       
      Returns:
      The user password of the PDF document, or null if no user password has been set.
    • setUserPassword

      public void setUserPassword(String value)
      Sets the user password of the PDF document.

      Use a high-entropy, unique password from secure configuration or a key management service. Do not hard-code this value in application code.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       String configuredUserPassword = getPdfUserPassword();
       options.setUserPassword(configuredUserPassword);
       
      Parameters:
      value - The user password of the PDF document, or null if no user password has been set.
    • getOwnerPassword

      public String getOwnerPassword()
      Gets the owner password of the PDF document.

      The owner password is required to change the permissions for the PDF document when these security options are applied during PDF export.

      Use a high-entropy, unique password from secure configuration or a key management service. Do not hard-code this value in application code.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       String configuredOwnerPassword = getPdfOwnerPassword();
       options.setOwnerPassword(configuredOwnerPassword);
       String ownerPassword = options.getOwnerPassword();
       
      Returns:
      The owner password for the PDF document, or null if no owner password has been set.
    • setOwnerPassword

      public void setOwnerPassword(String value)
      Sets the owner password of the PDF document.

      The owner password is required to change the permissions for the PDF document when these security options are applied during PDF export.

      Use a high-entropy, unique password from secure configuration or a key management service. Do not hard-code this value in application code.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       String configuredOwnerPassword = getPdfOwnerPassword();
       options.setOwnerPassword(configuredOwnerPassword);
       
      Parameters:
      value - The owner password for the PDF document, or null if no owner password has been set.
    • getPrintPermission

      public boolean getPrintPermission()
      Gets whether printing is allowed for the PDF document.

      This property controls whether the generated PDF can be printed. The default value is true.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setPrintPermission(false);
       boolean allowPrint = options.getPrintPermission();
       
      Returns:
      true if printing the PDF document is allowed; otherwise, false.
    • setPrintPermission

      public void setPrintPermission(boolean value)
      Sets whether printing is allowed for the PDF document.

      This property controls whether the generated PDF can be printed. The default value is true.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setPrintPermission(false);
       
      Parameters:
      value - true if printing the PDF document is allowed; otherwise, false.
    • getModifyDocumentPermission

      public boolean getModifyDocumentPermission()
      Gets whether modifying the PDF document is permitted.

      This property indicates whether users are allowed to modify the exported PDF document. The default value is true.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setModifyDocumentPermission(false);
       boolean allowModifyDocument = options.getModifyDocumentPermission();
       
      Returns:
      true if modifying the PDF document is permitted; otherwise, false.
    • setModifyDocumentPermission

      public void setModifyDocumentPermission(boolean value)
      Sets whether modifying the PDF document is permitted.

      This property indicates whether users are allowed to modify the exported PDF document. The default value is true.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setModifyDocumentPermission(false);
       
      Parameters:
      value - true if modifying the PDF document is permitted; otherwise, false.
    • getModifyAnnotationsPermission

      public boolean getModifyAnnotationsPermission()
      Gets whether commenting on the document is permitted.

      This property indicates whether annotations can be added or modified in the exported PDF.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setModifyAnnotationsPermission(false);
       boolean allowAnnotations = options.getModifyAnnotationsPermission();
       
      Returns:
      true if commenting on the document is permitted; otherwise, false.
    • setModifyAnnotationsPermission

      public void setModifyAnnotationsPermission(boolean value)
      Sets whether commenting on the document is permitted.

      This property indicates whether annotations can be added or modified in the exported PDF.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setModifyAnnotationsPermission(false);
       
      Parameters:
      value - true if commenting on the document is permitted; otherwise, false.
    • getFillFormsPermission

      public boolean getFillFormsPermission()
      Gets whether filling interactive form fields is permitted.

      This property indicates whether form fields can be filled in the exported PDF. According to the product documentation, this permission can still allow form filling even when getModifyAnnotationsPermission() returns false.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setModifyAnnotationsPermission(false);
       options.setFillFormsPermission(true);
       boolean allowFillForms = options.getFillFormsPermission();
       
      Returns:
      true if filling form fields is permitted; otherwise, false.
    • setFillFormsPermission

      public void setFillFormsPermission(boolean value)
      Sets whether filling interactive form fields is permitted.

      This property indicates whether form fields can be filled in the exported PDF. According to the product documentation, this permission can still allow form filling even when getModifyAnnotationsPermission() Sets false.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setModifyAnnotationsPermission(false);
       options.setFillFormsPermission(true);
       
      Parameters:
      value - true if filling form fields is permitted; otherwise, false.
    • getExtractContentPermission

      public boolean getExtractContentPermission()
      Gets whether copying or extracting content from the PDF document is permitted.

      This property indicates whether PDF content can be copied or extracted. Use setExtractContentPermission(boolean) to enable or disable this permission.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setExtractContentPermission(false);
       boolean allowExtractContent = options.getExtractContentPermission();
       
      Returns:
      true if copying or extracting PDF content is permitted; otherwise, false.
    • setExtractContentPermission

      public void setExtractContentPermission(boolean value)
      Sets whether copying or extracting content from the PDF document is permitted.
      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setExtractContentPermission(false);
       
      Parameters:
      value - true if copying or extracting PDF content is permitted; otherwise, false.
    • getAssembleDocumentPermission

      public boolean getAssembleDocumentPermission()
      Gets the permission to insert, rotate, or delete pages and create bookmarks or thumbnail images even if getModifyDocumentPermission() is not set.

      This property indicates whether PDF document assembly operations are allowed. Use setAssembleDocumentPermission(boolean) to enable or disable this permission.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setAssembleDocumentPermission(false);
       boolean canAssemble = options.getAssembleDocumentPermission();
       
      Returns:
      true if inserting, rotating, or deleting pages and creating bookmarks or thumbnail images is permitted; otherwise, false.
    • setAssembleDocumentPermission

      public void setAssembleDocumentPermission(boolean value)
      Sets the permission to insert, rotate, or delete pages and create bookmarks or thumbnail images even if getModifyDocumentPermission() is not set.
      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setAssembleDocumentPermission(false);
       
      Parameters:
      value - true if inserting, rotating, or deleting pages and creating bookmarks or thumbnail images is permitted; otherwise, false.
    • getFullQualityPrintPermission

      public boolean getFullQualityPrintPermission()
      Gets the permission to print in high quality.

      This property indicates whether the generated PDF allows faithful, high-quality printing.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setFullQualityPrintPermission(true);
       boolean allowHighQualityPrint = options.getFullQualityPrintPermission();
       
      Returns:
      true if high-quality printing is allowed; otherwise, false.
    • setFullQualityPrintPermission

      public void setFullQualityPrintPermission(boolean value)
      Sets the permission to print in high quality.

      This property indicates whether the generated PDF allows faithful, high-quality printing.

      
       PdfSecurityOptions options = new PdfSecurityOptions();
       options.setFullQualityPrintPermission(true);
       
      Parameters:
      value - true if high-quality printing is allowed; otherwise, false.
    • toString

      public String toString()
      Returns a string representation of these PDF security options.
      Overrides:
      toString in class Object
      Returns:
      A string representation of these PDF security options.