20 Replies Latest reply on Feb 2, 2011 8:31 PM by maxwyss

    Multiple document use of field.buttonSetIcon(...) is failing

    bleclerc

      We're trying to store a set of icons in a pdf document that can be shared by all the attached pdf documents.  The result of this would be then when we are in one of the attached documents (call it the child), we can read the icon from the parent document, and set it to a field created on the child document.  Here is the sample of the JS we're using ("this" pointer is for the child document)

       

          function CreateWidgetWithIcon(box, iconname)

          {

              var name = \"NewWidget\" + this.numFields;

              var master = GetRootDocument(); <-- this function returns to us the document that contains the icons

              var field = this.addField(name, \"button\", 0, box);

              field.buttonPosition = position.iconOnly;

              var sourcefield = master.getField(iconname);");

              var icon = sourcefield.buttonGetIcon();"

              field.buttonSetIcon(icon);

          }

       

      All the functions are returning exactly what we expect them to.  If the this.addField were changed to master.addField, the exact result we want happens, just in the wrong document.  But when this is run in the child document, and we try to create the field in the child document, when the icon is set to the field, we get:

       

          GeneralError: Operation failed.

          Field.buttonSetIcon:8:Bookmark undefined:Mouse Up

       

      Both document are open and disclosed when we run this.

       

      Is this an expected failure?  Is it possible at all to have a resource that is stored as part of one document but accessed by another?  ImportIcon and buttonImportIcon don't seem to fit our needs either as I need this to be an entirely self contained document, deliverable as one pdf.