These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to make deletePages a TrustedFunction?

Cyan
Registered: Jul 31 2011
Posts: 2

Hi everybody,
 
I have a config.js located in the User Javascript Folder with:
--------------------------------------------
myTrustPropagatorDelete = app.trustPropagatorFunction(function(doc,nStart,nEnd) {
app.beginPriv();
doc.deletePages(nStart,nEnd);
app.endPriv();
})
 
myTrustedDelete = app.trustedFunction(function(doc,nStart,nEnd) {
app.beginPriv();
myTrustPropagatorDelete(doc,nStart,nEnd);
app.endPriv();
});
 
mySaveAs = app.trustPropagatorFunction(function(doc,path) {
app.beginPriv();
doc.saveAs(path);
app.endPriv();
})
 
myTrustedSpecialTaskFunc = app.trustedFunction(function(doc,path) {
app.beginPriv();
mySaveAs(doc,path);
app.endPriv();
});
--------------------------------------------
 
And then I have a button with:
 
--------------------------------------------
console.show();
myTrustedDelete(this,0,0);
 
// build file name
var myFileName = "LastName" + "FirstName" + ".pdf";
// add folder name
myFileName = "/c/Users/Cyan/Desktop/" + myFileName
myTrustedSpecialTaskFunc(this, myFileName);
--------------------------------------------
 
I have tested this without "Security Policy" and it works fine.
 
But when I apply "Security policy" with Compatibility: Acrobat 9.0 and later, Restrict Editing and Printing of a Document, Printing Allowed: High Resolution and Changes Allowed: Commenting, filling in forms fields and signing existing signature fields, it just throw me an error:
--------------------------------------------
RaiseError: This operation is not permitted.
Doc.deletePages:3:Field Button4:Focus
===> This operation is not permitted.
--------------------------------------------
 
Can I somehow make a "login" on the "Security Policy" or something so the document can be change and then "logout"?? Or what is I'm suppose to do?
 
Thanks in advance!!!

My Product Information:
Acrobat Pro Extended 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You cannot use Acrobat JavaScript to remove security from a PDF. Password security is particularly difficult to deal with. However, I'm pretty sure that if you encrypt the PDF with a digital certificate that you own, then operations such as deleting pages can be performed because Acrobat automatically applies your credentials when the PDF is opened.

BTW: the trustPropagatorFunction doesn't do anything. Get rid of it.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You cannot use Acrobat JavaScript to remove security from a PDF. Password security is particularly difficult to deal with. However, I'm pretty sure that if you encrypt the PDF with a digital certificate that you own, then operations such as deleting pages can be performed because Acrobat automatically applies your credentials when the PDF is opened.

BTW: the trustPropagatorFunction doesn't do anything. Get rid of it.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Cyan
Registered: Jul 31 2011
Posts: 2
Hi Thom,

So if I use the digital certificate, no one can access my PDF, unless they have the password to do so.

If I use the digital certificate, do I need the trustPropagadorFunction?? How do I need to modify it so it can works for Digital Certificate?

Thanks.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Cyan wrote:
So if I use the digital certificate, no one can access my PDF, unless they have the password to do so.
No, you do not give them your password. The digital certificate consists of 2 parts a private one that use use to sign and protects PDFs and requires your password and a public version that you can distribute to others who will install the public certificate and then they will have access to PDFs you have protected with your private certificate and they can verify your signature. You do not pass around your password. You can find more information in Acrobat Help under Digital IDs.

Cyan wrote:
If I use the digital certificate, do I need the trustPropagadorFunction?? How do I need to modify it so it can works for Digital Certificate?

Your certificate does not change the application security restrictions as established by Adobe. The special script will reside on your computer in a special Acrobat application folder. But since you have the certificate on your computer, you will be known as the author of the PDF and full access. You may need to sign into your digital certificate.

George Kaiser