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

Programming Yes & No buttons

alex35.williamson
Registered: Nov 16 2011
Posts: 8

I have created a form for people to fill out. Once it has been filled out and the user presses the print button i want a warning dialogue to pop-up and remind them that once they print the form they cannot change it if they then close Adobe Reader.
 
I would like there to be Yes & NO buttons in the dialogue insted of the default OK and Cancel - The Yes button would simply mean "yes, i would like to continue printing" and the No button would mean "no, i would like to go back and check the document (cancelling the printing process)".
 
Can anyone help? I already have the caption of what I would like to say, I just need help with the JavaScript for the two buttons.

Thanks, Alex :-D

My Product Information:
Acrobat Pro 10.1, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Yes, you can do that with the app.alert method by specifying the corresponding value for the nType parameter, as shown in the documentation: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.135.php

The return value tells you which button the user pressed, so have your code check it and proceed accordingly.


alex35.williamson
Registered: Nov 16 2011
Posts: 8
This is what I've managed to assembled from that web page;

~~~

var nButton = app.alert({

cMsg: "Before continuing to print, check that the contents of your timetable is accurate and that you have spelt teacher's names and subjects correctly. Please take notice of these precautions because this document cannnot be saved once you have filled it in unless you have downloaded the doPDF PDF Printer which will enable you to save this. To check your document click cancel in the printer dialogue box and give it a once over.",

cTitle: "Before printing..",

nIcon: 1, nType: 2

});

if ( nButton == 3 ) end.Dialogue()
if ( nButton == 2 ) cancel.Printing();

~~~

Not sure about the commands in the last two lines (need help with those).

P.S. Ignore what the caption says, it needs work and i've not edited it.

ALSO, i've put the Script into the "Document Will Print" section in the Document Actions window - don't know if this makes a difference for what i'm trying to do.

Thanks, Alex :-D

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
That's the right idea, but as you suspected, those last two lines won't work and the Will Print event is not where you should place this. You cannot place code in the Will Print event to abort the printing. What you can do is place a button on your form that is labeled "PRINT" or something similar. When the user clicks it, it can run the app.alert code. If the use clicks the right button, then issue a "print" statement: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.511.php
alex35.williamson
Registered: Nov 16 2011
Posts: 8
Right there's a problem. When i was creating and formatting the text fields in the document i needed to get the alignment of the text in each field right so i used Adobe LiveCycle to do this. The only way i can edit the buttons and form fields now is in LiveCycle.

How do you open the JavaScript editor for a print button in LiveCycle? I honestly cant see how to do it - and will the JS work the same? :-D

Thanks, Alex :-D