8 Replies Latest reply on May 24, 2011 12:20 PM by George_Johnson

    Check Box Mask?

    Cypherlok

      Is there any way to create a white filled square over sections of my PDF using a checkbox?  I want the user to have the ability to print sections of the document if they check the box.  I am using this for labels and I hate to waste a bunch of labels for no reason.  Thanks for any advice.

        • 1. Re: Check Box Mask?
          Cypherlok Level 1

          Is there another option for me to create the ability to print only sections of a document?  I have 6 labels on a standard Avery label sheet.  We use all six labels for logos and serial numbers.  However, if we have 7 labels to print, we dont want to waste a new sheet on one label.  I want the employee to have the ability to print only the label he types a serial number into.  I was thinking the best way to do this is with masks and I can easily do this with photoshop or similar but I would like the employee to have the ability within Acrobat reader.  Thanks in advance =)

          • 2. Re: Check Box Mask?
            George_Johnson MVP & Adobe Community Professional

            There are a number of ways you could do this, but it's not clear to me how you have your PDF set up. Is the user entering serial numbers in text fields? Can you post a sample somewhere?

             

            Also, in your example of needing to print 7 labels, are you saying that you want to use a previously used label sheet where one of more labels have already been used?

            • 3. Re: Check Box Mask?
              Cypherlok Level 1

              George,

              Thanks for the quick reply. I am using a 2 across, 3 down Avery sheet label.  I created a template using inDesign with logos and FCC identification and published it to PDF.  I then added text fields for users to add a serial number and MAC address in over the existing template.  The problem is, if I only need one label, I type in the MAC address and serial number on one label, but it still prints the rest of the labels rendering them useless.  I would like the ability to mask any label that does not have a MAC address in field MAC1 through MAC6.  I can email you my document as it stands now if you would like but I'm not sure where I could post it online as I can't attach it here. Thanks again, you are a big help.

              • 4. Re: Check Box Mask?
                George_Johnson MVP & Adobe Community Professional

                OK, you can do that using a button that you place over each lable. A field can be set to be "hidden but printable" or just hidden, in addition to visible and "visible but doesn't print. So in the case where there is a serial number entered for a particular lable, you could set the button to hidden, causing the underlying label to print. WHen there is no serial number, set the button to hidden but printable. This assumes that you set up the button to have a white background, no border color, and is set to read-only so the user can't interact with it. To get the buttons that you add to be below the text fields you already have, place the buttons at the beginning of the tab order.

                 

                The script that you place in the Validate event of the serial number field might look something like:

                 

                // Validate script for serial number text field
                (function ()
                
                    // Get a reference to the button
                    var f = getField("B1");
                
                    // If there is a value in this field, set button to hidden
                    // otherwise set it to print, thus obscuring underlying graphic
                    f.display = event.value ? display.hidden : display.noView;
                
                })();
                

                 

                Change "B1" in the code above to match the name of the button that you add for the label.

                 

                This presumes that if you want to print a label, there will be a value in the serial number field. If that's not the case, you'll have to have a script in the MAC address field as well, but the code would be different since it would have to then check the values in both the serial number and MAC address fields and decide what to do.

                1 person found this helpful
                • 5. Re: Check Box Mask?
                  Cypherlok Level 1

                  George,

                  Great idea, I don't know why I didn't think about that.  So, I have added a button, no color, no border, tab 1, and set it to hidden but printable.  I have added your script into the MAC1 text field validation box but I think I am missing the function.  I get an error that the function is missing the "{" character.   I see the script gets the Button1 value but what checks MAC1 to see if there is anything in it?  Also, my text box MAC1 has a mask of OO:OO:OO:OO:OO:OO in it so I'm not sure if that will effect anything.  Please assume that I know nothing about scripting.  I am learning and the comments help so thanks!

                   

                  // Validate script for serial number text field
                  (function ()

                      // Get a reference to the button
                      var f = getField("Button1");

                      // If there is a value in this field, set button to hidden
                      // otherwise set it to print, thus obscuring underlying graphic

                      f.display = event.value ? display.hidden : display.noView;

                  })();

                  • 6. Re: Check Box Mask?
                    George_Johnson MVP & Adobe Community Professional

                    Soryy, there is a typo. The first line should be:

                     

                    (function () {
                    

                     

                    Also, the button should have a background color of white, but no border color.

                     

                    If you only place the script in the validate event of the serial number field, whatever is in the MAC address field does not matter.

                    • 7. Re: Check Box Mask?
                      Cypherlok Level 1

                      George,

                      Thank you again, your sir, are the man!  Just for my own knowledge, can you explain how this function below works?

                      f.display = does my variable display something right?

                      I am confused about display.hidden : display.noView; Aren't these the same thing?  which is for true and which is for false?  I assume this is a Boolean expression? Anyways, thanks for all the help, this will be used quite a bit in the future.

                       

                       

                      f.display = event.value ? display.hidden : display.noView;

                      • 8. Re: Check Box Mask?
                        George_Johnson MVP & Adobe Community Professional

                        It is just shorthand for:

                         

                        if (event.value) {
                            f.display = display.hidden;
                        } else {
                            f.display = display.noView;
                        }
                        

                         

                        This uses the ternary operator that's available in JavaScript: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special/Conditional_Operat or

                         

                        For more information on the display field property, see: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.700.html