4 Replies Latest reply on Nov 8, 2012 12:03 PM by George_Johnson

    How do I retain a PDF form widget's design when setting its value using Javacript in Acrobat?

    gediam

      I've been experimenting with interactive PDF forms in InDesign and JS in Acrobat. I think I've encountered something that might be a bug: widget design is overriden when using Javascript to set the field's value in Acrobat. Here's what a checkbox, for example, should look like when checked:

      http://i45.tinypic.com/axl6u.png

      However performing:

      var f = this.getField("Checkbox");
      f.value = "Yes";

      in the JS Console results in the widget's appearance defaulting to acrobat's:

      http://i49.tinypic.com/11qmm1g.png

      I've tried every single widget property documented in Acrobat's Javascript API Reference to no avail. Initially, checking/unchecking using the mouse works fine. Once the value has been set using JS, Acrobat's default black check character is used for all subsequent toggling, including when using the mouse...

      How does InDesign export interactive PDFs with custom icons for widgets? Is there any way to enforce the use of those icons using JS in Acrobat Pro? What's the difference between selecting a checkbox or a radio button using the mouse and setting its value using JS?

        • 1. Re: How do I retain a PDF form widget's design when setting its value using Javacript in Acrobat?
          try67 MVP & Adobe Community Professional

          Just a guess here, but maybe ID applies another font to the check boxes it

          creates (the default one is ZapfDingbats), to achieve this custom icon

          behavior, and perhaps the JS code resets the field to the default font

          setting. You can test it out by executing this code in the JS console

          (before changing the value, of course):

          this.getField("Check Box1").textFont

           

          If that's the case, then you're probably out of luck, since this property

          is read-only in JS, so you can't set it back to the custom font used.

          • 2. Re: How do I retain a PDF form widget's design when setting its value using Javacript in Acrobat?
            gediam Level 1

            I thought it might be the case, too, but all widgets have the same properties both before and after setting the value with JS. I did this check using all documented properties in Acrobat JS Reference in an attempt to figure out what might be going on.

             

            By the way, I don't think Indesign necessarily uses glyphs for the checked state of widgets, although in this case a glyph is used (albeit with different stroke and fill colours for the glyph, acrobat doesn't allow setting these properties AFAIK). With Indesign CS6 it seems you can practically use any Indesign tool to design the widget's On and Off states. So I'm thinking that maybe Indesign exports these with button-like properties where there are no restrictions on appearance (I think there is an "icon" property/object for buttons or something like that). However Acrobat treats them as checkboxes, so if that is the case it is more of a hack. Is there a way to probe an object's various properties other than using JS or the properties pop-up dialog?

            • 3. Re: How do I retain a PDF form widget's design when setting its value using Javacript in Acrobat?
              try67 MVP & Adobe Community Professional

              I think you're probably right about that... It seems ID and Acrobat are not

              fully compatible on this issue.

              You can use an external library or tool to read the properties of the PDF,

              such as iText, PDFBox, or something like that.

              • 4. Re: How do I retain a PDF form widget's design when setting its value using Javacript in Acrobat?
                George_Johnson MVP & Adobe Community Professional

                It's not a property that can be retrieved via JavaScript. Acrobat is simply not prepared to deal with the various appearances that InDesign sets and overrides them under certain conditions. There is nothing in the PDF spec that prohibits a nonstandard appearance for a radio buttons or check boxes, so it's really Acrobat behaving badly.

                 

                A long time ago I used to create custom appearances for check boxes by hacking the PDF, but Acrobat stared overriding them with I think Acrobat 6 (or 5) and I gave up. I was encouraged by the new forms-related features of InDesign, but there's still a lot of work to be done, both with InDesign and Acrobat, to make it really useful. This is one of the more glaring incompatibilities. You should report this as a bug with Acrobat, even though it is by design. We just need to try to get them to change the design.