Expand my Community achievements bar.

Allow print after filling mandatory fields using PrePrint

Avatar

Level 1

I have a form in which I want to add a button which will allow the user to print the pdf file only when two required fields namely Text1 and Text2 are filled in. The same shall apply to Ctrl P command also.

How can I do so?

During google search, I have found some stuff on this but since I am not very well versed with pdf js (even with js) I am not able to make it.

Can it be done in Adobe Live Cycle Designer ES? There is a 'PrePrint' event, but I have no clue on how to make it workable to my requirments?

Your help is highly appreciated.

Regards

Sujit Talukder

5 Replies

Avatar

Level 4

I think this might help. I should add that the question the user is asking is a bit different, but Radzmar has a link to his website where he lays out the steps and code to restrict printing on required fields. 

http://forums.adobe.com/thread/1034677

Avatar

Former Community Member

Completely disabling printing is an overly-complicated task.  You might be better off just hiding the form if the user tries to print when all required fields have not been completed.  You don't need to add a button for this.  Just go to the highest object in your hierarchy (defaults as "form1"), and enter this code.  Note:  This is using FormCalc, not JavaScript.

form1::prePrint - (FormCalc, client)

if (

   Text1.isNull or

   Text2.isNull

   )

then

   this.presence = "hidden"

   xfa.host.messageBox("This form does not allow printing of its contents until all required fields have been completed.  If you print now, the page(s) will be blank.  Please complete all required fields first, then printing of the form contents will be enabled.")

endif

You'll need to reference the exact locations for the two text fields, obviously, e.g. ContentArea.Subform1.Section2.Text1 or wherever you have them.

Then, on the postPrint event (it doesn't matter if you use FormCalc or JavaScript for this one):

form1::postPrint - (JavaScript, client)

this.presence = "visible"

Voila.  Now the user can only print a blank page unless they've completed all required fields.

Avatar

Level 1

Thank you Clintonfor the reply.

I have used the code, Pressing Ctrl+P is giving the message but thereafter the Print Dialog box appears and thereafter it prints the page as usual and not a blank page.

I have used the code as follows-

topmostSubform::prePrint - (FormCalc, client)

if (

topmostSubform.Page1.Name_of_the_Employee.isNull or

topmostSubform.Page1.PAN_of_the_employee.isNull

   )

then

   this.presence = "hidden"

   xfa.host.messageBox("This form does not allow printing of its contents until all required fields have been completed.  If you print now, the page(s) will be blank.  Please complete all required fields first, then printing of the form contents will be enabled.")

endif

and-

topmostSubform::postPrint - (JavaScript, client)

this.presence = "visible"

Where is the lacuna?

Avatar

Former Community Member

Is your form saved as a static PDF or a dynamic XML form? This will not work in a static PDF.