5 Replies Latest reply on Dec 19, 2013 11:23 AM by nabnub

    How do we use getDataObjectContents to import fields value from an attachment

    nabnub

      Hi everyone,

       

      I am testing this method on how to get a value from an attachment and put it on the current page opened, I've tried to do this: http://cjoint.com/13dc/CLruaj192OV_doc1.pdf

       

      using the exemple on the AJS reference, but it doesn't work could you please help me to figure out the issue

       

       

      var oDoc = this.openDataObject("attachment1");
      try {
      
      var myField = this.getField("Text");
      
      // get the value of "MarksTotal1" in PDF attachment
      
      var yourField = oDoc.getField("MarksTotal");
      
      // view this value in "Text"
      
      myField.value = yourField.value;
      
      oDoc.closeDoc();
      
      } catch(e) { app.alert("Operation failed");}
      
      

       

      tanks a lot

        • 1. Re: How do we use getDataObjectContents to import fields value from an attachment
          try67 MVP & Adobe Community Professional

          Use this code instead:

           

          var oDoc = this.openDataObject("attachment1.pdf");

          try {

          // get the value of "yourTextField" in PDF attachment

          var yourField = oDoc.getField("MarksTotal");

          // view this value in "myTextField"

          event.value = yourField.value;

          oDoc.closeDoc();

          } catch(e) { app.alert("Operation failed");}

           

          To make sure that you have the correct data object name you should access the dataObjects property of the document.

          • 2. Re: How do we use getDataObjectContents to import fields value from an attachment
            nabnub Level 1

            Thanks a lot Gilad,

             

            to update the modifications made on the attachment, I've created a button on the current page that reset the fields of the form and it does the work (but this was just to see how to use this.openDataObject) I don't know if it's okay to use this button when I will have a lot of scripts within this page??

            • 4. Re: How do we use getDataObjectContents to import fields value from an attachment
              nabnub Level 1

              Well I'll give it a try,  thank you Gilad,

               

              also I was wondering if this is possible (this is just an idea how to achieve my task, though it's seems brute)

               

              http://cjoint.com/13dc/CLsmVAN2o0r_test.pdf

               

              basically: on the attachment the user can choose names through out a popup menu (and it will return the names that I set in English first)

               

              then on the summary page (in which I import the fields value from the attachments in English as well) there are several page following it (certificates)


              I am trying to set a button that will fill the correct page accordingly (if results>99), if level tested is 1 the button will fill in the 2nd page with the names of the examiner and the pupil in Arabic (so the problem is that I wanted it in Arabic)

               

              where do I need to associate the Arabic names to the english names so the certificates are filled in Arabic, and how can I set this buttons to do the job

               

              could you please help me to see clear.

               

              thank you

               

               

              (also perhaps my approach to achieve my aim is not appropriate, if there is a better way then I am eager to learn new things)

              • 5. Re: How do we use getDataObjectContents to import fields value from an attachment
                nabnub Level 1

                I found a way of importing the associated arabic names, it's just to create a field on the attachments that receive the Arabic names and I set the color in white, then I import this field on the summary page, so this is done (later on I'll to find a way to write a function that would loop the fields I think it will be better)

                 

                At the moment but could you please help to find a solution to create the button that would fill in the correct certificate,

                 

                nabnub wrote:

                 

                I am trying to set a button that will fill the correct page accordingly (if results>99), if level tested is 1 the button will fill in the 2nd page with the names of the examiner and the pupil in Arabic

                (the condition is on the field Result1Row1 or Result1Row2 to be >99)

                 

                 

                 

                here is my file sample: http://cjoint.com/13dc/CLsmVAN2o0r_test.pdf

                 

                thank you