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

조회 수: 2 (최근 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에서 Call Python from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by