Re: Saving an encrypted PDF in Word 2016
Re: Saving an encrypted PDF in Word 2016
- Subject: Re: Saving an encrypted PDF in Word 2016
- From: Takaaki Naganoya <email@hidden>
- Date: Tue, 12 Sep 2017 20:04:06 +0900
You can set password to PDF by AppleScript itself.
<AppleScript>
-- Created 2015-10-20 by Takaaki Naganoya
-- 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "QuartzCore"
property kCGPDFContextOwnerPassword : a reference to current application's
kCGPDFContextOwnerPassword
property NSDictionary : a reference to current application's NSDictionary
property kCGPDFContextUserPassword : a reference to current application's
kCGPDFContextUserPassword
property |NSURL| : a reference to current application's |NSURL|
property PDFDocument : a reference to current application's PDFDocument
set userPassword to "12345"
set ownerPassword to "01234"
set aPath to (choose file of type {"com.adobe.pdf"} with prompt "Select PDF to
Encrypt")
set newF to choose file name with prompt "Input file name to save encryped pdf"
set aRes to my encryptPDF(aPath, newF, ownerPassword, userPassword)
on encryptPDF(aPath, newF, ownerPassword, userPassword)
set aURL to |NSURL|'s fileURLWithPath:(POSIX path of aPath)
set aPDFdoc to PDFDocument's alloc()'s initWithURL:aURL
set anEncF to aPDFdoc's isEncrypted()
if anEncF = false then
set newFp to POSIX path of newF
if newFp does not end with ".pdf" then
set newFp to newFp & ".pdf"
end if
set aDic to NSDictionary's
dictionaryWithObjects:{ownerPassword, userPassword}
forKeys:{kCGPDFContextOwnerPassword, kCGPDFContextUserPassword}
set aRes to aPDFdoc's writeToFile:newFp withOptions:aDic
return aRes as boolean
else
return false
end if
end encryptPDF
</AppleScript>
> 2017/09/12 1:43、Jeremy Roussak <email@hidden>のメール:
>
> I often send work I have done out as a PDF file, generated by Word using a
> script. I’d like to encrypt it: is it possible?
>
> save as aDoc file format format PDF file name pdfName password “pw"
>
> The dictionary suggests that you can add a password to a document and that
> you can save a document as a PDF, but combining the two doesn’t seem to work.
>
> Any other suggestions gratefully received.
>
> Jeremy
>
>
>
> Jeremy Roussak
> email@hidden
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
--
Takaaki Naganoya
email@hidden
http://piyocast.com/as/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden