Stefan Cameron on Forms
Building intelligent forms using Adobe LiveCycle Designer

Prevent Printing PDF Forms in Acrobat 8

This is something many of you have asked me about in the past and I never had a definite answer. The only method I knew of was to use a print button from the Object Library palette and add some checks for invalid data (or unfilled fields) inside its click event which is set to call by default. The problem with this method is that the user could still print using Acrobat’s print command (either via “File > Print”, the print button in the toolbar or by using “Ctrl + P”).

I didn’t know any better because, well, prior to Acrobat 8, there wasn’t really anything better and the reason was that form validations simply weren’t triggered prior to Acrobat receiving the command to print. So while you could easily prevent a form from being submitted electronically if validations failed, there was no definitive way to prevent it from being printed… until Acrobat 8 and XFA 2.5 came along, that is.

Advanced Tutorial: Before you read further, I should warn you that this is an advanced tutorial as it (unfortunately) requires editing the “XML Source” using Designer since Designer doesn’t have settings for this yet.

New Validate element in the Config DOM

In version 2.5, the Present element in XFA’s Configuration Document Object Model (“Config DOM” for short), which houses configuration options for XFA applications (such as Acrobat and Reader), was extended to have a Validate element.

This element can have any of four optional values, each separated by a space: “prePrint“, “preSubmit”, “preSave” and “preExecute”. By default, the element is not specified and the default behaviour (which is the same when the element is specified but contains no values) is to validate prior to submitting the form only. Once values are specified, then validations are run only prior to the specified events.

For example, if you wanted to have a form that prevents the user from printing but not submitting when a mandatory field is empty, you would specify the following validate element in the Config DOM (the ellipsis mean there’s other stuff in there; what’s important is the validate element inside the present element):


Unfortunately, this isn’t something that you can reliably set via script since these options are typically read-in on load and aren’t read again. Furthermore, Designer does not yet support setting the values in the validate element. In order to set this option, you’ll need to edit the XML Source in Designer and find the following markup about 2/3 way down:

<config xmlns="">
   <agent name="designer">
      <!--  [0..n]  -->

Once you’ve located the <present> element inside the <config> element (the Config DOM), you’ll need to insert the <validate> element:

<config xmlns="">
   <agent name="designer">
      <!--  [0..n]  -->

(Notice the <validate>prePrint</validate> element above.)

When you’re done making the change, click on the Design View tab and make sure you say “yes” to have your changes applied.

XFA 2.8/Acrobat 9 Update: With the release of XFA 2.8 and Acrobat/Reader 9.0, the <validate> element is now located under the <acrobat> element in the Config DOM:


To ensure backward compatibility, if the <validate> element is not found under <acrobat>, Acrobat/Reader will fall back to looking inside the old <present> to see if it’s defined there.

Now you’re probably wondering what the different values mean so here’s a quick explanation:

  • prePrint: Failed validations prevent the form from printing.
  • preSubmit: Failed validations prevent the form from being submitted electronically.
  • preSave: Failed validations will not prevent the form from being saved however Acrobat/Reader will issue a special warning message, after issuing the validation error message, to inform the user that the validations failed. I’m guessing this is because the user may be saving the form to continue filling it at a later time so the save can’t be completely prevented.
  • preExecute: Failed validations will prevent the form from executing a data connection (usually to a web service).

In all cases, any validation error messages will be displayed and this should work in Reader 8 as well. If you have set validation warnings (as opposed to errors), then the warnings will be displayed but the user’s action will not be stopped.

Sample Form

I took the time to put together a little sample form which demonstrates a Dynamic PDF form that cannot be printed nor submitted in Acrobat/Reader 8 and above unless the text field is filled.

Download Sample [pdf]

Minimum Requirements: Acrobat/Reader 8 or above.

Updated: December 20, 2008

Posted by Stefan Cameron on April 13th, 2008
Filed under Acrobat,Designer,Tutorials
Both comments and pings are currently closed.

48 Responses to “Prevent Printing PDF Forms in Acrobat 8”

  1. JM on June 11th, 2008

    I try it and work, but when I change a textbox, or code or anything and save the line
    is moved under after and before without reason 🙁 and then stop working.

    any ideas ? best regards and sorry my bad english 🙂

  2. Stefan Cameron on June 14th, 2008


    I’m afraid I don’t understand what’s happening. Could you try to give me more details? When are you changing a text box? What text box are you changing? Can you try to clarify “the line prePrint is moved under after and before”?

  3. Matt Duchesne on June 17th, 2008

    This was really helpful and I must say excellent work. I do have a question though, I placed the code where it needed to be and it works on my machine which has a full version of acrobat. But when a coworker opens the same file with the latest version of reader it fails. Any help or insight would be greatly appreciated. Thanks

  4. Matt Duchesne on June 17th, 2008

    I found the issue to be the difference with the revision of reader. I would like to know what type of script you have added and where to check for current revision, Reader 8 or higher.


  5. Stefan Cameron on June 22nd, 2008

    Matt Duchesne,

    The validate element will only be interpreted by Acrobat and Reader 8.0 or later. You can check for the version by using (in JavaScript)

    if (parseInt( >= 8)...

    The property will return a string that represents the major and minor versions. For Reader 8.1.2, it will return “8.1.2”.

    If you still need to check whether the form is running in Acrobat or Reader, you can do

    if ( == "Reader")...
  6. Matt Duchesne on June 23rd, 2008

    Thank you for the response, you and your site has been a tremendous help. Since I am new at this, where would I place the check version script? Thanks in advance.

  7. Stefan Cameron on June 25th, 2008

    Matt Duchesne,

    That’s really up to you. For instance, you could put it in the root subform’s (called “form1” by default, at the top of the tree in the Hierarchy palette) Initialize event and issue a message box if the application is Reader and its version is less than 8:

    if (parseInt( < 8 && == "Reader")"This form is not compatible with this version of Reader.");

    Of course, using Designer 8.1, you could set the target version to be "Acrobat 8 or later" and then opening the form in Reader or Acrobat lesser than 8 would automatically issue a warning to the user that a later version of Acrobat/Reader is required to use it.

  8. Matt Duchesne on June 27th, 2008

    Thanks again. I have another question I posted it at AUC but have not gotten a response yet. Obviously I am a beginner to all of this but I have a form and within the form are fields that are user defined. From the value that is entered I would like to populate two other fields, a min (entered value minus 1) and max (entered value plus 1) which are the allowable ranges. I have not had any luck and was hoping you might shed some light on the subject.

  9. Stefan Cameron on June 29th, 2008

    Matt Duchesne,

    Assuming all 3 fields concerned are numeric, you can do this quite easily in Designer by using Calculate event scripts on the min and max fields. Say the reference field (the one in which the user enters a value) is named “refField”. First, set the “min” and “max” field’s “Object palette > Value tab > Type” to “Calculated – Read Only” and specify that a script is used for the calculation. Then, using the Script Editor palette with the “Show” drop down list set to “Calculate” (after selecting the “min” field), you would set the script as follows:

    refField.rawValue - 1;

    Similarly for the “max” field, you would set the following script:

    refField.rawValue + 1;

    Now, whenever the value of “refField” is changed, the values of “min” and “max” will also change automatically.

  10. Chris on July 3rd, 2008

    Hi there,

    Im a total newbie in creating forms with Designer – I actually started using it this week! But I’ve been able to get where I wanted to so far, except for one thing…one big thing, in fact.

    I made my whole form, it works well when I try to fill it in and when I send it to myself. The problem is when I try to import the data in the form. What I’d like to do is to see the form exactly the way it was when the “client” filled it in before he sent it by email. I don’t want just a text file with all the answers one above the others, I really want to see the answers appear in the right field, in the form I created.

    I don’t know if all of this is clear enough for you to help me out, but thanks anyway – I found lots of other tricks on your site 🙂


  11. Chris on July 3rd, 2008

    Hey there,

    I just found out the answer to my problem so I thought I might as well post it here in case someone else needs it. It was posted by Daniel Wittwer rigt there:

    First: If you use the submit by email button, only xml is available as a choice. Instead, insert a Button, browse to the Object tab, and you will find the submit tab. Submit to URL: “mailto:” This will open the email application. Here you can set submit as PDF.

    The XML file can be read in a standard text editor, or a xml parser.

    Second: I believe you can only save the forms using Acrobat. For Acrobat Reader, I think you must enable Reader Extensions to be able to save the form.

    I hope this helps you.

    Hope it helps too!


  12. Stefan Cameron on July 13th, 2008


    One thing to note is that the free Reader cannot submit a form in PDF format unless the form has been extended using Reader Extensions. If this isn’t an option for you, you can always let the form’s data be submitted as an XML file and then use Acrobat’s “import form data” feature to load the submitted XML data back into a blank copy of your PDF in order to see the submitted data in the same way as the user submitting the form had filled it in on your form.

  13. Duane on July 16th, 2008

    Hi Stefan,

    Interesting bit of information regarding the printing prevention in Acrobat 8; I have run into this issue on countless occasions. However, the above workaround doesn’t seem to provide a clean means to prevent File->Print action based on custom validation (ie. scripted validation) but rather only on validation as set in the object pallet.

    As I see it, this can be used to ensure that mandatory fields have been filled. However while it is possible to restrict http submission of a form based on successful validation of logic through a script object – I require a way to prevent the File->Print operation depending on the success of validation script in a script object (ex. ensuring business rules between various sections of the form have been observed).

    I can cause the script to update a hidden, required field to allow/block the File->Print functionality … unfortunately Adobe Acrobat/Reader seems to have an unconfigurable standard app.alert error message which says “At least one required field was empty on export. Please fill in the required fields (highlighted) before continuing”. This message would be very confusing for the user, as the unfilled mandatory field is not the true source of the failed validation; it was merely a means to report the result of the validation script object.

    Is there any way to change this message? If not, have you scoped out another way to approach blocking the File->Print functionality of Acrobat/Reader dependent on the success of a script object performing validation logic?

    Please bear in mind that I am not using an XML schema, so loading in validation rules or messages from a schema is not an option.

    Any info to help out is greatly appreciated.

  14. Matt Duchesne on July 21st, 2008

    Hey Stefan,

    Thanks for all the help and I am back with more questions. We have recently upgraded to Acrobat 9 and the new version of Live Cycle Designer. Getting better but still have a lot of ground to cover. My questions is this: Can I have the user click a button maned Save Form and they will be able to save the file to a specified location on their network location but populate the name with field information (ie. the description+serial number+date) This will hopefully eliminate any overwrite and have the ability to look up test data from certain days. Trying to eliminate a long paper trail. Let me know when you can.

  15. Stefan Cameron on July 26th, 2008

    Matt Duchesne,

    I’m afraid there are a couple of problems with a “save form” button: The first is the fact that on its own, the free Reader will not let you save a PDF form unless the PDF has been extended for export rights using LiveCycle Reader Extensions ES. The second is the fact that you would not be able to force the user to save the form using a specific name, neither would you be able to suggest a default name in the “Save As” dialog.

    If you’re users are using Acrobat Standard or Pro/Extended, they’ll be able to save the form however you still won’t be able to pre-populate the file name with some default name.

  16. Matt Duchesne on July 28th, 2008


    Thank you for the clarification. I had a feeling that the request was going a bit to far but, you never know until you ask. I appreciate the help and thanks again.

  17. Matt Duchesne on July 28th, 2008


    Would you be able to help, yet once again? I am having problems setting up conditional fields. This is what I am trying to do:
    if (Field1=YES) then (Field2=PASS)
    elseif (Field1=NO) then (Field2=FAIL)
    I keep getting a syntax error, and I am not sure how to remedy it. Is this a FormCalc, can the fields be drop downs or another type for the script to run. A
    lso is there anything else that needs to be set-up before hand. If and when you can and as always thanks.

  18. Stefan Cameron on July 30th, 2008


    After a lot of digging and consulting with my colleagues, I finally have an answer for you: It seems that at the moment, the result of script validations is not respected unless the field on which the validation fired has been filled (is non-empty). This means that if you’re calling a script object function that validates something and returns true/false from a field’s Validate event, Acrobat will not respect a failed validation (returning false) if that field doesn’t have a value. I would explain why if I understood it myself but personally, I don’t agree with the way this works. Nonetheless, this is the reality of the situation in Acrobat/Reader 9 and previous versions.

    As for Acrobat/Reader’s message about some mandatory fields not being filled, I don’t believe there’s any way to change it.

    Finally, I don’t know of any other definitive way to prevent printing from Acrobat/Reader. There used to be ways to remove the “File > Print” menu item, even the print toolbar button but even if this is still possible in Acrobat/Reader 9, you wouldn’t be able to catch the use of the “Ctrl + P” key sequence so the user would always have some way to circumvent your validation code in order to print the form.

  19. Stefan Cameron on July 30th, 2008

    Matt Duchesne,

    The equality operator in FormCalc is a double-equals (==) just like in JavaScript. That could the syntax error you’re getting. Also, the FormCalc engine likely can’t understand what YES, PASS, NO and FAIL mean. I’ll take a guess that these are string values, in which case they should be surrounded by double-quotes. Try specifying it like this:

    if (Field1 == "YES") then
        Field2 = "PASS"
    elseif (Field1 == "NO") then
        Field2 = "FAIL"
  20. Duane on August 4th, 2008

    Much appreciated.

    Just wondering how assured it is that the validate element will remain within the Config DOM going forward? Is it safe to implement solutions based of this XML Source edit, or is there a potantial for losing compatibility with future versions of Reader/Acrobat?


  21. Matt Duchesne on August 6th, 2008

    Thanks Stefan.
    Once again I appreciate the help.
    Here is another one for you: Can you put parameters on a field? A min/max of a fixed value? If the max is 4.5 can I prevent the user from entering 4.6 and conversely if the min is 0.5 then they can’t enter 0.4. I think that this is a Min/Max script but just wanted to be sure, thanks.

  22. Stefan Cameron on August 8th, 2008


    You can safely use this method to prevent printing. The only reason why you need to manually edit the XML Source to set the <validate> element in the Config DOM is because Designer doesn’t provide UI to make it easy to do.

    And yes, it’s safe to use the setting.

  23. Duane on August 11th, 2008

    Thanks Stefan,

    Following up on this theme, I’ve run into a further problem that maybe you can shed light on. Let’s assume I have included the above approach to limit printing if mandatory fields have not been filled.

    It would appear that the rawValue of any object is set upon the exit event of that object.

    If a user has focus within a mandatory field and enters a value, and then clicks a button on the form which calls app.print – the focus will leave the field, the exit event will fire, the rawValue will be assigned, and the print will be successful. (Of course, this is independent of the fix which you have illuminated).

    Rather than clicking a button on the form, if the user instead clicks the Print Icon in the Acrobat toolbar, again the exit event will fire, the rawValue will be assigned, and the Print will be successful.

    However, if instead, the user moves the mouse up to the toolbar and clicks on File, then scrolls down and clicks on Print – the pre-print event fires before the exit event. The rawValue for the field is not set, and Printing is blocked because Acrobat believes that a mandatory field has not been set. The behavior is the same if the user enter the Cntr-P hotkey to print.

    Do you know why File -> Print and Cntr-P behave differently from the Print Icon, by firing pre-print validation before exit events? Is there any way to force the XFA model to update the value of the field? I’ve tried changin focus on a pre-print event to hopefully cause the rawValue to be commited, but no such luck.

    Any insight into this would be greatly helpful; since at this point I don’t think the Print Prevention approach can be implemented in a production form, as it will fail if the user happens to be inside a mandatory field when they select File-> Print or Cntr-P.


  24. Stefan Cameron on August 13th, 2008

    Matt Duchesne,

    Unfortunately, numeric or decimal fields don’t have min/max properties that you can set. You would need to control this via script — possibly by scripting the Exit event of the field to check that the number is in the correct range:

    if (this.rawValue < 0.5)
        this.rawValue = 0.5; // force the value back to the minimum
    else if (this.rawValue > 4.5)
        this.rawValue = 4.5; // force the value back to the maximum

    This works because the field’s rawValue property has been updated with the value entered by the user at the time of the Exit event.

  25. Stefan Cameron on August 13th, 2008


    That’s a really good point. The problem you’re experiencing is due to the fact that selecting an item from a menu or using keyboard sequences does not cause a change in focus in the application, thereby not causing focus to move away from the field, thereby not causing the Exit event to fire.

    Normally (on Windows), clicking on a toolbar button has the same effect however it appears that this special case is handled. I’m going to take this back to the Acrobat Team to make sure the “Ctrl + P” and “File > Print” cases are handled as well.

    Thanks for bringing this to my attention!

  26. Duane on August 14th, 2008

    Thanks Stefan.
    I’ll check back here for any update.

  27. Matt Duchesne on August 21st, 2008

    Here is the recent encounter with LSD. I have a form, on the form is a NumericField1 (located on page 2). I have put a validate script : this.rawValue >= 2.40 && this.rawValue <= 2.60; Then if the user enters a value outside the range an alert box pops up and states: “The numeric value you are entering in is outside the acceptable range for this test procedure. Please check your data.”

    I now have another NumericFiled2 (located on page 4). Here I would like to enter the value of NumericField1 but perform a calculation: (NumericField1 * 100) – 5

    I keep getting an Error accessor, pretty much saying the value is undefined. I have done this on another form but without the validate script and both fields were on the same page.
    If this makes any sense, do you think you could help. Thanks so much.

  28. Stefan Cameron on August 25th, 2008

    Matt Duchesne,

    It looks like you’re not accessing the “rawValue” property of the “NumericField1” field in your Calculate script for “NumericField2” (assuming you’re scripting in JavaScript). Also, if “NumericField2” is in a different container (subform) (which it very well may be if it’s on a different page), you may need to provide a path expression to “NumericField1” from “NumericField2”. Something like:

  29. Paul Pelletier on August 26th, 2008

    Hey Stefan,

    I have a related question that is kind of off base. I have an email submit button on a form that is being validate by using the preSubmit element. However what I am trying to accomplish is if a certain dropdown box is populated then I want to set the mailto: attribute to that value. For example if someone selected “Paul” from the dropdown I want to set the mailto: to Is this even possible? I was thinking of using a simple if else if statement to accomplish but I cannot figure out what the mailto property actually is on the submit button, is emailsubmit.rawvalue or what? I have tried that to no avail and I am kind of stuck and wondering if it’s even possible. Any and all help/advice would be greatly appreciated! Thanks!

  30. Paul Pelletier on August 27th, 2008

    Here is the script I am trying to use on a regular button (not an email button):

    if (topmostSubform.Page3.txt_BoatName.rawValue= “Boat1″){cUrl:”” ?Subject=”Boat1 Completed App/Waiver”, bEmpty: true, cSubmitAs: “PDF”, cCharset: “utf-8”});
    else if (topmostSubform.Page3.txt_BoatName.rawValue= “Boat2″)
    {{cUrl:”” ?Subject=”Boat2 Completed App/Waiver”, bEmpty: true, cSubmitAs: “PDF”, cCharset: “utf-8”});
    else if (topmostSubform.Page3.txt_BoatName.rawValue= “Boat3″)
    {{cUrl:”” ?Subject=”Boat3 Completed App/Waiver”, bEmpty: true, cSubmitAs: “PDF”, cCharset: “utf-8”});


    This form is Reader enabled as well, if I just use a regular email button with a static button I have no problems at all, but the email address will not always be the same, it will be based on what is in that text field, whcih is populated from a drop down list using the xfa.event.newtext routine. Thanks again.

  31. Paul Pelletier on August 27th, 2008

    Sorry for the confusion, that was actually the wrong code, I have no Idea what I was thinking, but here is the right script:

    if (topmostSubform.Page3.txt_BoatName.rawValue== “Boat1″) then{cUrl:”” ?Subject=”Boat1 Completed App/Waiver”, bEmpty: true, cSubmitAs: “PDF”, cCharset: “utf-8”})
    elseif (topmostSubform.Page3.txt_BoatName.rawValue== “Boat2″) then{cUrl:”” ?Subject=”Boat2 Completed App/Waiver”, bEmpty: true, cSubmitAs: “PDF”, cCharset: “utf-8”})
    elseif (topmostSubform.Page3.txt_BoatName.rawValue== “Boat3″)then{cUrl:”” ?Subject=”Boat3 Completed App/Waiver”, bEmpty: true, cSubmitAs: “PDF”, cCharset: “utf-8”})

    Thanks again!

  32. Stefan Cameron on August 28th, 2008

    Paul Pelletier,

    You can also do this entirely on the XFA side (as opposed to using the AcroForm API). See my new tutorial on submitting form data by email.

  33. Theo on November 21st, 2008

    Hi stefan,

    How we can validate two check boxes before printing?
    Checks boxes are Yes, No and the user have to check one.


  34. Stefan Cameron on November 28th, 2008


    If you’re using Acrobat/Reader 8 or later you may be able to use the techniques described in this post (though you may need to use a radio button list instead of two checkboxes to make it work). Otherwise, you would have to use the two button submit technique and use a Print button instead of a Submit button.

  35. nep on December 16th, 2008


    Can you tell me one way to change the xfa by code, so one can set the prePrint node in runtime?

    Thank you

  36. Stefan Cameron on December 20th, 2008


    Unfortunately, you can only query for the setting via script at runtime. It’s a read-only property since the Config DOM options are loaded at document start-up and aren’t looked-at afterwards.


    will get you the current setting. You can also set the value (i.e. there’s no error when you try to set it) however there is no effect. If you check it afterwards, you’ll see it’s still set to whatever it was set to in the XML Source.

  37. Pat Oregon on May 11th, 2009

    Can you tell me, Stefan, how to affect the border color/thickness that results from the prePrint validation? When it sees required fields that have not been populated, it places a wide red border around each field. Any way to modify that?

  38. Stefan Cameron on May 19th, 2009

    Pat Oregon,

    That red border is generated by Acrobat/Reader. If there’s a way to modify it, I think it would be in the Preferences for the application itself and not necessarily overridable with code.

  39. Adobe Developer on May 24th, 2009

    Dear Stefan;

    Can I customize this message “At least one required field was empty on export. Please fill in the required fields (highlighted) before continuing” to any other string ? and if yes, how can I do that ?


  40. Stefan Cameron on May 25th, 2009

    Adobe Developer,

    Unfortunately, you can’t customize it. Your only option is to do your own validation and show your own dialog with your own message.

  41. Duane on December 2nd, 2009

    Hello Stefan

    Just wanted to follow up on our discussion (above) from August 13, 2008.

    You had mentioned that you would see if you could approach the Acrobat team to address the problem with File->Print and Cntrl-P not changing focus within Acrobat (and therefore not committing the rawValue for the field which the user currently has in focus).

    I had also reported this issue through the Enterprise Support team and was told that it was tagged as a “future enhancement” for Acrobat 9.x

    Just wondering if you have heard anything back from this – as I have resumed testing with the latest version of Acrobat and this problem is still present.

    It would be very helpful to have a robust method of preventing printing based on validation.
    – Duane

  42. Stefan Cameron on December 5th, 2009


    I had indeed reported this issue to the team back in Aug 2008. Unfortunately, it didn’t make the cut for Acrobat/Reader 9 (as you concluded yourself). All I can say here is that they are considering a fix for a future release of Acrobat/Reader. You should get in touch with Enterprise Support if you want/need more information than that…

  43. Harry2ca on April 9th, 2010

    Hi Stefan,

    Is there anyway to get the “At least one required field was empty on export. Please fill in the required fields (highlighted) before continuing” message in the form?
    In other words, which event in form happens after the message?


  44. Stefan Cameron on April 14th, 2010


    This message will appear after the Validate event fires. The sequence of events is “Validate > FormReady > LayoutReady” when the form is opened, then “Validate > LayoutReady” when you’re changing its value.

    If you’re using Designer 9.0 with XFA 3.0, there is a new “ValidationState” event that fires whenever a field’s valid state changes from valid to invalid or invalid to valid. This event occurs immediately after the Validate event, if the state changes, followed by the other events in the sequence.

  45. DocDengler on May 27th, 2010


    Thanks so much for the tutorial … in a matter of minutes my forms were behaving as I hoped they would!

  46. Stefan Cameron on June 6th, 2010


  47. Mitesh on August 16th, 2010

    Hi Stefan,

    I used your <validate>prePrint</validate> solution to validate required field before printing. Everything works very smoothly. But we recently found a problem. When pdf is opened in the browser, prePrint validation works perfectly if user clicks “Print” button in embedded adobe toolbar in the browser. But if user clicks File -> Print menu in the browser, it shows the validation message and then browser hangs and I have to “End Task” the browser. I am not sure anyone has faced this problem. Could you please let me know if there is any solution to this problem.



  48. Stefan Cameron on August 26th, 2010


    I hadn’t heard of this before but I did confirm the behaviour with IE8 and Acrobat 9.3.3. IE8 hanged and I had to kill iexplore.exe using the Task Manager.

    Thanks for bringing this to my attention. I will report it.