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

Override Window's Print Function - validation

EdwardKuk
Registered: May 14 2010
Posts: 26
Answered

Hi Everyone,

I am trying to to warn my users of which fields are not validated before they print. I have placed pre-print code (below) to ask the user if they want to validate the form prior to printing. However, when they hit yes, the code should tell the form not to print. It probably does this, but window's print function happens anyways, ignoring the entire issue. Any idea how to override window's print function as well?

Thanks for your help,
Edward Kuk
CODE:

var valid;
var redo = 3; // assume no redo
valid = MainPage.execValidate();
if (!valid) {
redo= xfa.host.messageBox("Do you want to fix the validation errors before printing?", "Question", 2, 2);
}
if (redo != 4) {
// YES = 4, NO = 3, OK = 1, Cancel = 2
//If they chose yes, this overrides the print function
xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);
}

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
See this tutorial from Stefan Cameron.

[url]http://forms.stefcameron.com/2008/04/13/prevent-printing-pdf-forms-in-acrobat-8/[/url]

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

EdwardKuk
Registered: May 14 2010
Posts: 26
Thanks Radzmar,

You always understand my problems right away and give me the problem solution :).

Best Regards,
Edward Kuk
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi Edward,

you can also execute your script, when the users press Ctrl + P.
Therefore you simply need ot add this code to the pre:print event of you form.

MainPage.Body.SubmissionMethods.PrintButton.execEvent("click");
and add one more thing to the your print buttons script

PayeeInfo.VendorInfo.EmplID.mandatoryMessage = PayeeInfo.Tax.T4a.rawValue == "2" ? "Employee ID is required when employee reimbursement is selected." : null;PayeeInfo.VendorInfo.SIN.mandatoryMessage = PayeeInfo.Tax.T4a.rawValue == "3" || PayeeInfo.Tax.T4a.rawValue == "4" ? "SIN is required for T4A payments." : null;var redo;var valid;redo = 3; // assume no redovalid = MainPage.execValidate();if (!valid) {redo = xfa.host.messageBox("Do you want to fix the validation errors before printing?", "Question", 2, 2);}if (redo == 3) {// YES = 4, NO = 3, OK = 1, Cancel = 2xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);}else{xfa.event.cancelAction = 1;}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs