How can I add javascript text fields to Acrobat pages from Applescript please?

I have a real need to add text fields to Acrobat document pages from Applescript. I can't access the Headers and Footers from Applescript in Acrobat XI. I can set watermarks using the following script, but cannot for the life of me work out how to add text fields. Any advice please?
Regards
set TempAttachmentName to "(20140717121212Z)"
set PreserveFileName to "This is a test"
set bypass to false
tell application "Adobe Acrobat Pro"
  activate
  set CountOfPages to count of pages
  repeat with PageCounter from 1 to CountOfPages
  tell application "System Events" to tell process "AdobeAcrobat"
  try
  click menu item "Page..." of menu 1 of menu item "Go To" of menu 1 of menu bar item "View" of menu bar 1
  tell current application to delay 0.1
  keystroke PageCounter as text
  tell current application to delay 0.1
  keystroke return
  if not bypass then
  my ADDHeaderFooter(TempAttachmentName, PreserveFileName & " " & CountOfPages, PageCounter)
  end if
  end try
  end tell
  end repeat
end tell
on ADDHeaderFooter(The_String1, The_String2, currentPage)
  tell application "Adobe Acrobat Pro"
  activate
  set myDocument to document 1
  tell myDocument
  tell page currentPage
  set cbox to crop box
  set item 2 of cbox to (item 2 of cbox) + 44
  set item 4 of cbox to (item 4 of cbox) - 44
  set media box to cbox
  set crop box to cbox
  set theResult1 to my Add_WaterMarkText(The_String1, "IDAutomationHC39M", 12, 1, 1, 1, 0, 3, 10, 3, 0)
  do script theResult1
  set theResult2 to my Add_WaterMarkText(The_String2, "Times", 16, 1, 1, 1, 0, 4, 10, -6, 0)
  do script theResult2
  end tell
  end tell
  end tell
end ADDHeaderFooter
on Add_WaterMarkText(cText, cFont, nFontSize, nS, nE, nTA, nHA, nVA, nHV, nVV, nR)
  set Params to "cText: '" & cText & "'," & return
  set Params to Params & "cFont: '" & cFont & "'," & return
  set Params to Params & "nFontSize: '" & nFontSize & "'," & return
  if class of nS is integer then set Params to Params & "nStart: " & (nS - 1) & "," & return
  if class of nE is integer then set Params to Params & "nEnd: " & (nE - 1) & "," & return
  -- 0 = left, 1 = centre, 2 = right
  if class of nHA is integer then set Params to Params & "nHorizAlign: " & nHA & "," & return
  -- 3 = top, 4 = bottom
  if class of nVA is integer then set Params to Params & "nVertAlign: " & nVA & "," & return
  -- offset in points
  if class of nHV is integer then set Params to Params & "nHorizValue: " & nHV & "," & return
  -- offset in points
  if class of nVV is integer then set Params to Params & "nVertValue: " & nVV & "," & return
  if class of nR is integer then set Params to Params & "nRotation: " & nR & "," & return
  set javascript to "this.addWatermarkFromText({" & Params & "});"
  return javascript
end Add_WaterMarkText

G'day
Unfortunately I don't have the API. My Adobe Reader installation updating to version XI failed, and subsequent attempts to fall back on the X version are blocked by the partial install of XI. Damn Adobe stuff.
Could someone please post the relevant part of the API to give me some pointers, please.
I ha mucked about with some information I found on the Web, and come up with the following, which fails because I can't work out how to address the current document with the variable myDoc.
Regards, Brian
set Params to Params & "var myDoc = this;" & return
set TempAttachmentName to "(20140717121212Z)"
set PreserveFileName to "This is a test"
set bypass to false
tell application "Adobe Acrobat Pro"
  activate
  set CountOfPages to count of pages
  repeat with PageCounter from 1 to 1 # CountOfPages
  tell application "System Events" to tell process "AdobeAcrobat"
  try
  click menu item "Page..." of menu 1 of menu item "Go To" of menu 1 of menu bar item "View" of menu bar 1
  tell current application to delay 0.1
  keystroke PageCounter as text
  tell current application to delay 0.1
  keystroke return
  if not bypass then
  my ADDHeaderFooter(TempAttachmentName, PreserveFileName & " " & CountOfPages, PageCounter)
  end if
  end try
  end tell
  end repeat
end tell
on ADDHeaderFooter(The_String1, The_String2, currentPage)
  tell application "Adobe Acrobat Pro"
  activate
  set myDoc to document 1
  tell myDoc
  tell page currentPage
  set cbox to crop box
  set item 2 of cbox to (item 2 of cbox) + 44
  set item 4 of cbox to (item 4 of cbox) - 44
  set media box to cbox
  set crop box to cbox
  set theResult1 to my Add_WaterMarkText(The_String1, "IDAutomationHC39M", 12, 1, 1, 1, 0, 3, 10, 3, 0, myDoc)
  do script theResult1
  set theResult2 to my Add_WaterMarkText(The_String2, "Times", 16, 1, 1, 1, 0, 4, 10, -6, 0, myDoc)
  do script theResult2
  end tell
  end tell
  end tell
end ADDHeaderFooter
on Add_WaterMarkText(cText, cFont, nFontSize, nS, nE, nTA, nHA, nVA, nHV, nVV, nR, myDoc2)
  #set Params to "var myDoc = app.newDoc();" & return
  set Params to ""
  set Params to Params & "var myDoc = this;" & return
  set Params to Params & "var inch = 72;" & return
  set Params to Params & "var Bbox = this.getPageBox(" & "\"Crop\"" & ");" & return
  set Params to Params & "var f = myDoc.addField(" & "\"Text1\"" & ", " & "\"" & cText & "\"" & ", 0, [72, Bbox[1]-inch, Bbox[2]-2*inch, Bbox[1]-2*inch ] );" & return
  set Params to Params & "f.strokecolor = color.black;" & return
  set Params to Params & "f.richText = true;" & return
  set javascript to Params
  return javascript
end Add_WaterMarkText

Similar Messages

  • How can I add a "search" field for web pages content-not blogs or podcasts?

    This seems to be such a basic function, I can't believe I'm having so much trouble. I don't have a blog or a podcast on my new website that I'm in the process of designing. So how do I allow people who'll visit my site to search there for specified content? The only instructions I find are for the RSS in inspector for blogs or podcasts. All I want is for people to be able to search my site/web pages (that have no blogs or podcasts on them). This must be a common request... or am I crazy? How do I do that?
    Thanks for your help.

    I think I've answered my own question after a few hours of searching:
    http://services.google.com/searchcode2.html?accept=on
    Thank you Google.

  • How can I get the "text" field from the actionEvent.getSource() ?

    I have some sample code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.ArrayList;
    public class JFrameTester{
         public static void main( String[] args ) {
              JFrame f = new JFrame("JFrame");
              f.setSize( 500, 500 );
              ArrayList < JButton > buttonsArr = new ArrayList < JButton > ();
              buttonsArr.add( new JButton( "first" ) );
              buttonsArr.add( new JButton( "second" ) );
              buttonsArr.add( new JButton( "third" ) );
              MyListener myListener = new MyListener();
              ( (JButton) buttonsArr.get( 0 ) ).addActionListener( myListener );
              ( (JButton) buttonsArr.get( 1 ) ).addActionListener( myListener );
              ( (JButton) buttonsArr.get( 2 ) ).addActionListener( myListener );
              JPanel panel = new JPanel();
              panel.add( buttonsArr.get( 0 ) );
              panel.add( buttonsArr.get( 1 ) );
              panel.add( buttonsArr.get( 2 ) );
              f.getContentPane().add( BorderLayout.CENTER, panel );
              f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              f.setVisible( true );
         public static class MyListener  implements ActionListener{
              public MyListener() {}
              public void actionPerformed( ActionEvent e ) {
                   System.out.println( "hi!! " + e.getSource() );
                   // I need to know a title of the button (which was clicked)...
    }The output of the code is something like this:
    hi! javax.swing.JButton[,140,5,60x25,alignmentX=0.0,alignmentY=0.5,
    border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@1ebcda2d,
    flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,
    disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,
    right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,
    rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=first,defaultCapable=true]
    I need this: "first" (from this part: "text=first" of the output above).
    Does anyone know how can I get the "text" field from the e.getSource() ?

    System.out.println( "hi!! " + ( (JButton) e.getSource() ).getText() );I think the problem is solved..If your need is to know the text of the button, yes.
    In a real-world application, no.
    In a RW application, a typical need is merely to know the "logical role" of the button (i.e., the button that validates the form, regardless of whether its text is "OK" or "Save", "Go",...). Text tends to vary much more than the structure of the UI over time.
    In this case you can get the source's name (+getName()+), which will be the name that you've set to the button at UI construction time. Or you can compare the source for equality with either button ( +if evt.getSource()==okButton) {...}+ ).
    All in all, I think the best solution is: don't use the same ActionListener for more than one action (+i.e.+ don't add the same ActionListener to all your buttons, which leads to a big if-then-else series in your actionPerformed() ).
    Eventually, if you're listening to a single button's actions, whose text change over time (e.g. "pause"/"resume" in a VCR bar), I still think it's a bad idea to rely on the text of the button - instead, this text corresponds to a logical state (resp. playing/paused), it is more maintainable to base your logic on the state - which is more resilient to the evolutions of the UI (e.g. if you happen to use 2 toggle buttons instead of one single play/pause button).

  • How can I program the text fields in my email forum to have rounded corners

    How can I program the text fields in my email forum to have rounded off edges or corners. 
    this is the code im using.
    // insert code here// insert code here// prepare email field
    var email = sym.$("email")
    email.html("Enter your Email: ");
    inputEmail = $('<input />').attr({'type':'text', 'value':'', 'id':'email'});
    inputEmail .css ('font-size', 14);
    inputEmail .css ('width', 350);
    inputEmail .css ('background-color', '#4e4e4e');
    inputEmail .appendTo(email);
    // prepare topic field
    var topic = sym.$("topic");
    topic.html("Topic: ");
    inputTopic = $('<input />').attr({'type':'text', 'value':'', 'id':'topic'});
    inputTopic .css ('font-size', 14);
    inputTopic .css ('width', 350);
    inputTopic .css ('background-color', '#4e4e4e');
    inputTopic .appendTo(topic);
    // prepare message field
    var message = sym.$("message");
    message.html("Message: ");
    inputMessage = $('<textarea />').attr({'type':'textarea','rows':'10', 'cols': '25','value':'', 'id':'message'});
    inputMessage .css ('font-family',"Arial,Helvtica,sans-serif");
    inputMessage .css ('color',"#ffffff");
    inputMessage .css ('font-size', 14);
    inputMessage .css ('background-color', '#4e4e4e');
    inputMessage .css ('box-shadow', '#4e4e4e');
    inputMessage .css ('width', 350);
    inputMessage .css ('height', 150);
    inputMessage .appendTo(message);
    var submitBtn = sym.$("btn");
    submitBtn.html("Submit");
    submitBtn.css("text-align", "center");
    submitBtn.css("font-size",14);
    submitBtn.css("font-weight","bold");
    submitBtn.css("color","#ffffff");

    Try this: inputEmail.css ('border-radius', '25px');
    attachment
    more details

  • How can i add STORAGE LOCATION field which is not...............

    hi,
    sap gurus,
    good morning to all,
    how can i add STORAGE LOCATION field which is not in the standard tables namely
    KOMP, KOMK, and KOMG.
    how to include it in our FIELDS FROM FIELD CATALOGUE.
    if we include this field is there any impact on the standard tables.
    plz let me know this.
    bcz
    we are selling our products in two ways
    (1). one is straight from factory ie direct sales from factory
    if customer asks for excise invoice then we will sell thru factory and keeping freight in mind we will
    deliver him which ever is economical either rail or road.
    before coming to second case of selling the goods
    we will do STOCK TRANSPORT ORDER from plant to different storage locations.
    if we did STO thru road we have to sell the goods thru road only.
    if we did STO thru rail we have to sell the goods thru rail route only.
    (2). if the customer is not asking any excise invoice then we will send the goods thru depo/storage
    location which is not registered under excise.
    if the goods came by road then it will be delivered by road only.
    if the goods came by rail then it will be delivered by rail only.
    my logic here is
    basing on the
    storage location, transportation types, and distance i want to create condition record
    that captures exact frieght at the sales order level.
    confirm whether i am right or wrong.
    regards,
    balaji.t
    09990019711.

    Hi,
    It is not recommended to add new fields to any SAP standard tables. It disturbs the whole SAP functionality.
    But if you have no choice expcept to change the standard tables to meet your requirement -  then you need an access key to modify the object, which is available from the market place.
    Nevertheless, the better option is to create a 'Z' table with the required fields and use that accordingly.
    Changing standard tables will have serious impact when you apply patches or do an upgrade on the existing functionality.
    REWARD POINTS IF HELPFUL
    Regards
    Sai

  • How can I add the the field in the database in JSP?

    How can I add the the field in the MS access using JSP?

    By using JDBC.
    http://java.sun.com/docs/books/tutorial/jdbc/index.html

  • Is there a fax cover template?  If not, how can I have 2 text fields on one line?

    Is there a fax cover template?  If not, how do you add two text fields on one line?    

    No fax cover template. This forum posts explains how to put multiple fields on one line:
    http://forums.adobe.com/message/5032849

  • How can i make a search field in my app using applescript?

    I am making an app and i would like to learn how can i add a search field, that will search the content of a window. BTW i am using xcode and applescript

    Like pretty much all of the Cocoa documentation you will need to convert from Objective-C, but take a look at the Search Fields documentation.

  • How can i get my imac proceed to home page from restarting endlessly?  it will start then start booting then chime then bck to step one, not even hitting the start up page.... plssss help!

    how can i get my imac proceed to home page from restarting endlessly?  it will start then start booting then chime then bck to step one, not even hitting the start up page.... plssss help!

    Hi
    My Powerbook was the same. Only fix is to reinstall OSX from the install CD but be sure not to pick the Format and install clean. Once you boot with the install CD pick the preserve user data and settings.
    On My machine the reinstall looked perfect. My network, email, files and all the programmes were all there. Most apps worked fine but Adobe CS2, Virtual PC and NetBarrier all needed reinastallation as they reported a few files or registration was missing. I went for the 10.4.3 upgrade again and it worked fine.
    Good luck
    D

  • How can I have a text field that auto detects a previous entry?

    Like I have a text field example "First Name" and I want to be able to add another text field that will auto detect that input.

    Hi,
    Sorry we do not support this.
    To add a feature request please go to http://forums.adobe.com/community/formscentral?view=overview and click on "Submit Feature Request" in the Resources section on the right.
    To vote for an existing feature request already entered in our database, please go to  http://forums.adobe.com/community/formscentral?view=overview and click on "View Feature Request" in the Resources section on the right.
    Thanks,
    Lucia

  • How can i add filename on a document in pages 5.1 ?

    I am allways using a template to make documents, that I save under different names. How can I add the (changed) filename in the footer of a saved document ?
    It is important to me to print the filename on document, to find and edit it on my mac later.
    In MS Word it is easy to automaticaly add filenames, path, author and other filedata to the document. I can't find how to do that automatically in Pages templates.
    I saw earlyer answers to this question on this community, but they don't work as I expect, or only on earlier versions of pages.....  I trust there is an easy way to do this.
    Can someone help me please ?

    That function, present in "Pages 09" (i.e. Pages 4.3) , was not included in Pages 5.0-5.1.  (Nor were nearly 100 other such features, from mail merge and bookmarks to non-contiguous text selection, 2-up page viewing and the ability to set alternating left/right margins, headers & footers.Version 5.1 is also notably buggy. One work around, or partial work around, is to click the file name at the top of the window document. You can then select the filename, copy it  and paste it whereever you like. As far as I can see, however, there is no way to include the path: all you get is the filename and extension.

  • How can I view the text messages sent and received from my phone?how can I view the past text messages sent to my phone

    How can I view the text messages sent and received on one of the other phones on my plan?

    You would have to view them on the other phone.

  • How can I change the text in an iPhoto book from Spanish to English?

    How can I change the text in an Iphoto book I'm trying to create from Spanish to English??

    In the Creative Cloud Application you can change in Preferences the App language. Then you can download and install additional the other language.
    With Photoshop you can now go to Preferences > User Interface and switch between all installed and available languages.

  • How can I add a new field for Belgium in T588M?

    Hi experts,
    I am trying to change the infotype 0002 screen for BElgium. This is how I am doing T588M > new entry > MP000200 > alt. screen 2012 > var. key 12 >  feature p0002 >.
    I also maintained 12 as the var. key for the countr yBE in P0002 feature. I want to add P0002-GBDEP (state) field which is already there for MP000200 screen 2000 which is the SAP standard screen. why it  does not copy this field when I create this field for Belgium. HOw can I bring it for BEl. Please advise.
    Thanks a ton,
    JEss...

    As P0002-GBDEP is not included in screen '2012', you'll need to create an additional custom screen to show this field. Then, you'll need to config table 'T582C' to have 'MP000200' / screen '2012' to have this custom screen as an 'include' screen (e.g. if your new custom screen is ZP000200 / screen '0100', then in T582C, you'll need an entry with 'MP000200' '2012' ZP000200' '0100'.

  • How can I add a text substitution for changing st in 1st to superscript?

    I would like to add text substitutions for 1st, 2nd, 3rd, etc. so the letters show up as superscript. I attempted to change the st, nd & rd to superscript in Pages and tried to paste it, but it simply changed it back to regular format. How can I go about changing this?
    Thank you in advance for your help!

    It only works in TextEdit consistently for me. Mail forgets as soon as I sent the message. Pages doesn't even have an Edit > Substitutions menu, nor it is there anything in the inspector.
    So I use [Typinator|http://www.ergonis.com/products/typinator>, which works system-wide, no fuss, and it's more powerful than the built-in text substitution. Another alternative is [Text Expander|http://smilesoftware.com/TextExpander>.
    If the free trails and price still can't help you decide, see this [discussion|http://www.macheist.com/forums/viewtopic.php?id=13544] comparing the two.
    Edit: I eat my words. Getting Typinator to substitute superscript is tricker than I thought.
    Message was edited by: Sam_P

Maybe you are looking for