Expand my Community achievements bar.

Disable Print from menu/toolbar from Designer 7

Avatar

Former Community Member
Hello,



I have a form that contains a print button, which is only executed if all validation rules are executed successfully. However, I still have the Print function in the menu and the toolbar of Acrobat/Reader. In the forum I found an entry stating that you should check out the AcrobatJS Guide and try hideMenuItem(). It seems that I could use this function also in Designer, but I get a 'NotAllowedError' when I try to call it. The Guide says that for security reasons you can only use this function in application initialization or console events. Any idea where I can find these events in Designer 7? Or does anyone know the related function in Designer 7? Or is it not possible to do this with Designer?

I was also thinking if I could change the menu item, so that it takes my validation beforehand. I tried to put this in the prePrint event. Which really called my validation, however it still printed it afterwards. Any idea how I can stop the printing on failure of the validation?



Regards, Karin
5 Replies

Avatar

Former Community Member
Take a look in the Acrobat Scripting reference for the section about Trusted Functions. You need to use hideMenuItem() in one of those.



Also, you can't stop a print from the pre-print event if validation fails. Once it's that far it can't be stopped.



H.

Avatar

Former Community Member
Hello Hubert,



you don't happen to have a sample or something? I tried to implement the hideMenuItem like it is described in the Acrobat scripting reference, but I still got the 'NotAllowedError'. I really find it confusing because some things of the Acrobat scripting is also working in Designer, others are not. Do you know if there is a documentation about this, like which Acrobat function can be used in Designer, which not, and which Acrobat function is named different in Designer, etc.?



Regards, Karin

Avatar

Former Community Member
Here's JavaScript function that uses hideMenuItem to hide the print command:



hideFunc = app.trustedFunction(function () {

app.beginPriv();

try {

app.hideMenuItem("Print");

} catch (e) {

console.println("Error: " + e);

}

app.endPriv();

});



You'd put this inside a .js file under the /Acrobat/JavaScripts/ folder (you may need to restart Acrobat to get it to pick it up, I'm not sure). Then in your form you would trigger this by calling hideFunc().



H.

Avatar

Former Community Member
Hello Hubert,



thanks a million for the sample. It works great! My code almost looked the same, but it seems I missed something out.



One last question, and sorry, if it might sound stupid, but what do I have to do, when a customer is downloading my form, filling it out and printing it. Do I have to send the .js with the file? Will it still work on the customer's PC? Do I have to work with cookies?



Thanks!



Regards, Karin

Avatar

Former Community Member
In order to make options disapear from a users UI through script on a form the script requires special security priviledges which the user agrees to give you by placing your .js in the directory. If your clients do not place the .js there, the script will not work.



H.