8 Replies Latest reply on Jun 23, 2011 2:33 PM by Jeremiah29-11

    Merge two data values into one text field?

    Jeremiah29-11

      I have a PDF form that merges data from a database. The questions is can TWO different data elements be mapped to ONE text field? I am hoping to create one text field that imports the product name and the year of copyright with 4 spaces in between. Like this:   PRODUCT NAME    ©2011

      Does anyone know if this is possible?

        • 1. Re: Merge two data values into one text field?
          George_Johnson MVP & Adobe Community Professional

          What you can do is create two separate hidden text fields for the two pieces of data, and set up another visible field that combines the two other field values in the way you want, using a custom Calculate script. Something as simple as:

           

          // Custom Calculate script

          event.value = getField("f1").valueAsString + "    " + getField("f2").valueAsString;

           

          Where f1 and f2 are the names of the hidden fields.

          • 2. Re: Merge two data values into one text field?
            Jeremiah29-11 Level 1

            Thanks for the reply. I'm using Acrobat to edit the form. Is there a code view somewhere so I can try your suggestion? My experience is limited to what can be done using only the interface, but I am familiar with editing html code.

             

            As far as your suggestion, the tricky part is that each product name has a different length, and I want the copyright year to be inserted into the flow with some space in between. Don't the text fields have fixed display positions on the form page? Is there a way to make one relative to another so that no matter what the length of the product name data that is merged into the field is, the copyright year data will always appear approximately 4 character spaces following? See example below of how I would like the data elements to display/align:

             

            Connect The Dots    ©2011
            Vox    ©2009
            X-factor    ©2010

             

            Our database has the elements (product name and copyright year) separated and they can't be combined for other reasons. Appreciate the help!

            • 3. Re: Merge two data values into one text field?
              George_Johnson MVP & Adobe Community Professional

              When you bring up the field properties dialog for a text field, there will be a Calculate tab. When you select it you will see where you can enter a custom script. The script I posted adds the four spaces between the two values. The text field just needs to be wie enough to display all of the characters. Note that if you want to italicize the copywrite data, you will have to use a text field that allows rich text formatting (it's one of the options for a text field), and the script would be more involved than what I posted.

              • 4. Re: Merge two data values into one text field?
                Jeremiah29-11 Level 1

                George-you have been SO helpful! It's working so far! There are still 2 small formatting issues to fix. Do you think you can help?

                 

                1. Spacing. It doesn't seem to recognize the 4 spaces between values. Instead only 1 space is showing up. Just as a test, I replaced the 4 spaces with 4 dashes and these don't show up either. Is there an alternative to space them apart a little?

                 

                2. Italicize type. I checked the boxes for "rich text format" in both the the hidden and visible fields and this characteristic isn't showing up.

                 

                -J.V.

                • 5. Re: Merge two data values into one text field?
                  Jeremiah29-11 Level 1

                  Scratch the spacing issue. That's working fine now. I'm still trying to figure out the Italic characteristic.

                  • 6. Re: Merge two data values into one text field?
                    Jeremiah29-11 Level 1

                    It seems like the properties of the visible field are overwriting those of the hidden fields. Do you know of a way around that?

                    • 7. Re: Merge two data values into one text field?
                      George_Johnson MVP & Adobe Community Professional

                      Jeremiah29-11 wrote:

                       

                      It seems like the properties of the visible field are overwriting those of the hidden fields. Do you know of a way around that?

                      I'm not sure what you mean. Can you clarify what properties are being changed and when?

                       

                      Regarding setting rich text, you have to build up the field value using spans, as explained in the documentation: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.721.html

                       

                      So instead of setting event.value in the script, you'd set event.richValue after you create the appropriate spans. If you get stuck, post again.

                      • 8. Re: Merge two data values into one text field?
                        Jeremiah29-11 Level 1

                        Sorry, I wasn't very clear. I'm refering to the Italic property in the hidden copyright field. I would also like to make it 5pt size instead of 6pt. However, the visible field that displays the hidden field's value is the one that seems to be controling the way the text appears (size, color, font, etc.).

                         

                        The documentation you provided is somewhat helpful, but I'm not familiar with editing this type of script. Would it be difficult for you to provide a framework (as you did above) and tell me where to copy/paste it?

                         

                        My fields are currently set up like this:

                         

                        'Pattern' (this is the hidden field that merges data for the Product Name)

                             Text properties: Font:Gill Sans MT; Size:6pt; Color:Black;

                         

                        'Copyright' (this is the hidden field that merges data for the Copyright Year)

                             Text properties: Font:Gill Sans MT Italic; Size:5pt; Color:Black;

                         

                        'PatternCopyright' (this is the visible field that displays data for the above 2 fields)

                             Text properties: Font:Gill Sans MT; Size:6pt; Color:Black;

                         

                        Data in the 'Pattern' field looks fine because it is the same as the visible field. The copyright differences do not show up.

                         

                        Thanks so much for everything!