In this simple topic, you will gain an understanding of how to convert XLSX to PDF having restricted permissions using Python. Sometimes it is intended to forward some information to others but with imposed restrictions like restricting them to copy or print the document. The following steps entails the process to generate PDF having restricted permissions from XLSX using Python.
Steps to Convert XLSX to PDF having Restricted Permissions using Python
- Set the IDE to use Aspose.Cells for Python via Java to apply the restricted permissions on the exported PDF
- Load the source Excel file for exporting to a PDF using an instance of the Workbook class
- Create an instance of the PdfSaveOptions class object to configure the output PDF properties
- Apply the restrictions to extract the content and print the exported PDF
- Save the workbook as a PDF with restricted permissions
The steps mentioned above describe the process to export Excel to PDF having restricted permissions using Python, whereby the process will commence by loading the source XLSX file using an instance of the Workbook class. Then by using the instance of the PdfSaveOptions, the security permissions are accessed, and required restrictions are applied to desired PDF. Finally, a PDF with restricted permissions will be saved on the disk or inside the memory stream.
Sample Code for Excel to Restricted Permissions PDF using Python
The above example code generate PDF having restricted permissions from XLSX using Python with very few simple API calls. One can also include more restrictions including the requirement of a password to open by setting PdfSaveOptions.getSecurityOptions().setuserPassword(). It is pertinent to mention that the print restrictions and copy/extract will remain effective and UserPassword is just for opening the PDF file.
In this topic, we focused on converting XLSX to PDF having restricted permissions using Python. If you are interested in learning about the process to adjust the row heights inside the Excel worksheet, refer to the article on how to adjust row height in Excel using Python.