Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Sometimes, developers need to work with encrypted PDF files. For example:
This article explains how to pass in PDF security options when saving spreadsheets to PDF.
Aspose.Cells for Python via .NET provides PdfSecurityOptions for working with security. You can set owner and user passwords while saving to PDF. The owner password or user password will be required to open the encrypted PDF document for viewing.
The sample code below describes how to secure PDFs with Aspose.Cells for Python via .NET.
| from aspose.cells import PdfSaveOptions, Workbook | |
| from aspose.cells.rendering.pdfsecurity import PdfSecurityOptions | |
| # The path to the documents directory. | |
| dataDir = "./" | |
| # Open an Excel file | |
| workbook = Workbook(dataDir + "input.xlsx") | |
| # Instantiate PDFSaveOptions to manage security attributes | |
| saveOption = PdfSaveOptions() | |
| saveOption.security_options = PdfSecurityOptions() | |
| # Set the user password | |
| saveOption.security_options.user_password = "user" | |
| # Set the owner password | |
| saveOption.security_options.owner_password = "owner" | |
| # Disable extracting content permission | |
| saveOption.security_options.extract_content_permission = False | |
| # Disable print permission | |
| saveOption.security_options.print_permission = False | |
| # Save the PDF document with encrypted settings | |
| workbook.save(dataDir + "securepdf_test.out.pdf", saveOption) |
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.