Message Boards Message Boards

0
|
4396 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Encrypt PDFs exported from Mathematica

Posted 3 years ago

Hello everyone,

I have a workflow that outputs PDFs. The files are tests for my students. The procedure is roughly the code shown below put inside a Do loop.

nb = CreateDocument[{}]; NotebookWrite[nb, 
 Cell["[someTextHere]", "Text"]];
(*more text on more pages*)

Export[exportPath <> theFileNameStr <> ".pdf", nb];
NotebookClose[nb]

I encrypt each file manually by creating a password as well as disabling copying and printing. Is there a way to do that programmatically with Mathematica either during export or by running shell commands? I have never used shell but I understand that there is Python code for encrypting PDFs on Macs.

Greg

POSTED BY: Gregory Lypny
2 Replies
Posted 3 years ago

Hi Greg,

I don't think WL supports this. You can use the command line tool qpdf to do it. It can be invoked from WL using Run or RunProcess. Use Homebrew to install qpdf on a Mac.

POSTED BY: Rohit Namjoshi
Posted 3 years ago

Much obliged, Rohit. I will look into Homebrew and qpdf.

Greg

POSTED BY: Gregory Lypny
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract