Hello Saujandu,
It seems you are interested in finding a method to password-protect your PDF generated from ‘mlreportgen.dom’ in a manner compatible with MATLAB. This can indeed be achieved by utilizing the ‘pikepdf’ library in Python to secure the PDF file, and then invoking this Python script from MATLAB.
Below, is the code snippet that illustrates how Python can be used to password-protect a PDF file.
- Simply provide a new file name and password
- Then save this code into a Python file.
pikepdf.open("<Name of file to be Password Protected>").save(<"New name for the file>", encryption=pikepdf.Encryption(owner="<OwnerPassword>", user="<UserPassword>", R=4))
After saving the code, execute this Python script from MATLAB using the ‘system’ command.
- Provide the path to Python installation (i.e., the path to the Python executable file) and,
- Provide path to the Python script containing the code snippet above, as inputs to the ‘system’ command.
Here is the syntax for doing so:
system(' "C:\Users\...\Programs\Python\Python38\python.EXE" "Python file name.py" ');
Please refer to the attached documentation to get additional details on the ‘system’ command,
Hope it helps!