Is there any provision to password protect the PDF generated using mlreportgen.dom

5 次查看(过去 30 天)
I am trying to password protect the document genearted using mlreportgen.com. It may be done using PDFtk but I am not sure how it works with MATLAB, please suggest any method.

回答(1 个)

Tejas
Tejas 2024-3-26
编辑:Rena Berman 2024-7-16
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.
import pikepdf
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!

类别

Help CenterFile Exchange 中查找有关 Python Package Integration 的更多信息

产品


版本

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by