Expand my Community achievements bar.

Dectecting File>Print

Avatar

Level 2

Hey everybody, found this forum very usefull in the past and have been searching these forums for my current problem but haven't found any info.  I have several issues but lets start with this one.

I need to be able to dectect if the user has selected File>Print and if they have then do the following:

1) Pop up a warning message.  This message is to say to use the print button on the form it self.
2) Show a previously hidden page on the form and hide all the other pages.  The user then will essentially only be able to print a "useless" page which will have some instructions on how to print properly.


I'am able to show and hide pages using the script " xfa.resolveNode("page3").presence = "hidden"; "

I'am able to pop up a warning message using the script " xfa.host.messageBox("This is a test message!"); "

Not sure if the above two bits of script are going to be useful or not but I guess what I'm looking for is for a way to detect if the use has clicked the File>Print and then run the above two scripts.  I'm new to LiveCycle designer and scripting.

Kind regards,
SCF

3 Replies

Avatar

Former Community Member

There is a prePrint event that will run no matter how the user invokes a print (your button, File/Print or Ctrl - P). So you can program something there ....there is no command that I am aware of that will tell you which method was used to call your program but you can use the command xfa.event.name command that will tell you what the last event was that fired. If they click your print button you get the word click back ....if they choose Ctrl-P or File Print you will get other back instead. So your code woudl look something like this:

var tempEvent = xfa.event.name

if (tempEvent == "click"){

     //your print button was pressed

     xfa.host.print .......

} else {

     //print was invoked by another means

     do the code that will hide the pages and put up your print page....

}

Hope that helps

Paul

Avatar

Level 2

Thanks so much Paul, your soultion worked perfectly.

I came up with a solution which I was going to post up but it was kind of backwords and not so lean.  What I did was to create a hidden checkbox which will get ticked if the user clicks the print button.  I would then have an if statement in a simlar fasion to say if the check box is ticked the user has clicked the print button and as such show the correct pages and allow them to print.  If the checkbox wasn't ticked it would hide the pages and pop up an error message.  Although my solution worked its way too clunky and will be using your solution.  Thanks so much for the help.

Avatar

Former Community Member

Hi,

I am facing a problem on similar lines..

Is thr any way of getting the Print event action on printing PDF.

Please see my blog --

http://forums.adobe.com/message/3659933#3659933

Please suggest.

Thanks and Regards--

Chalukya.