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

4 ビュー (過去 30 日間)
Saujandu
Saujandu 2024 年 3 月 21 日
編集済み: Rena Berman 2024 年 7 月 16 日
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 Center および File ExchangePython Package Integration についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by