Secure PDF Documents

Contents
[ ]

Aspose.Cells APIs provide the PdfSecurityOptions class for working with the security of PDF file format. The sample code below describes how to create secured PDF files with Aspose.Cells for Java API.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(SecurePDFDocuments.class);
// Open an Excel file
Workbook workbook = new Workbook(dataDir + "input.xlsx");
// Instantiate PDFSaveOptions to manage security attributes
PdfSaveOptions saveOption = new PdfSaveOptions();
saveOption.setSecurityOptions(new PdfSecurityOptions());
// Set the user password
saveOption.getSecurityOptions().setUserPassword("user");
// Set the owner password
saveOption.getSecurityOptions().setOwnerPassword("owner");
// Disable extracting content permission
saveOption.getSecurityOptions().setExtractContentPermission(false);
// Disable print permission
saveOption.getSecurityOptions().setPrintPermission(false);
// Save the PDF document with encrypted settings
workbook.save(dataDir + "securepdf_test.pdf", saveOption);