Access DOM from context menu (javascript)

Hi,
I' trying to create a script to extend InDesign.
Here is my scenario:
Open InDesign file
Import XML data in the layout
For one item in the XML tree, in a context menu, load external data from a custom webservice.
I'm able to create the context menu, but what I don't know how to do is to get the right XML node when focusing on an item from the layout.
Does someone know how to access DOM with Javascript script?
Thanks.
Lionel

Hi Lionel,
It really depends on what you want to target. If your item is at the first level ( not into a group ), you can adress it either by its index or its name or its label if any:
var pi = app.activeDocument.pageItems[0]
or
var pi = app.activeDocument.pageItems.itemByName ( "foo" ); //given that the name of the object is foo in the layer palette.
or
var pi = app.activeDocument.pageItems.itemByID ( 123 ); //given that the id of the object is 123.
if you want to adress an object with a specific label, it's longer process. You have to loop every pageItems and compare their label.
Also if you know the nature of the object, you may target the collection directly :
var tf = pp.activeDocument.textFrames[0];
On the contrary if your intention is to work on the xml node, you may also loop through the xml structure.
To be honest, there are several ways to work in your case.
In any cases, don't hesitate to read the InDesign Scripting Guide which would answer most of these topics
Loic
PS: I prefer stick to my bad english as english spoken people may need this info

Similar Messages

  • Way to get access to the context menu

    I assume there is no official way to get access to the context menu, so you can add a menu item when, say, you right-click on a photo in the publish service collection. You can tweak the behaviour for the two existing items, but there does not seem to be a way to add your own.
    Regular menu Export, Library, Help menu items are too coarse, as they apply across the whole app. It would be nice to be able to add an item that invokes a script to do some stuff to the item.
    I can hack in a workaround using the various edit collection callbacks, but this is a kludge of the highest order.

    Context menu access would be nice. If squeaking helps, maybe an FR - I've already cast one, and assume Adobe only counts one per person...

  • Make "Manage Substitution Rule" from context menu to as button on UWL

    Hi Experts,
         We have requirement that "Manage Substitution Rule" link from context menu on UWL to make it as a button on UWL as "Manage Substitution Rule".  Anyone has done this kind of requirement before.  If you do please let me know the steps.  Award full points will be given to answer.  Thank you.
    With Regards,
    Sudheer.

    Hi,
    you can download the standard XMl file ad modify it by writting hte below code.and rename the file and upload it with high priority. and clear the cashe after uploading the file.
    1.code to create the specific action.
    in the action name below instead of xyz can be any name
    <Action name="launchSubstitutionManager_xyz" groupAction="" handler="SAPWebDynproLauncher" referenceBundle="SubstitutionManager" returnToDetailViewAllowed="yes" launchInNewWindow="SHOW_HEADERLESS_PORTAL" launchNewWindowFeatures="width=800,height=600,resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,directories=no">
    <Properties>
    <Property name="WebDynproApplication" value="UWLSubstitution"/>
    <Property name="WebDynproDeployableObject" value="sap.com/tckmcbc.uwl.ui~wd_ui"/>
    <Property name="isnewwindow" value="1"/>
    <Property name="type" value="button"/>
    <Property name="launchContext" value="UWL"/>
    <Property name="ignoreWorkIdParams" value="yes"/>
    <Property name="appContext" value="${context.appContext}"/>
    <Property name="System" value="SAP_LocalSystem"/>
    <Property name="display_order_priority" value="-1"/>
    </Properties>
    </Action>
    2. in the required view add the below code.
    <Action reference="launchSubstitutionManager_xyz"/>
    3. save your own the xml file and upload it with high priority.
    4. cleare the UWL cashe and browser cashe.
    5. relaunch the URL with the end user id.
    Raji.

  • Remove "Personalize Link" from context menu of iViews.

    HI,
    We have to disable / hide the "Personalize Link" from context menu of all  iViews in the portal.
    we do not want to go to Properties of individual iViews and change that.
    Is their any global setting for that?
    _vishal

    Hi Vishal,
    Are you talking about the Pesonalization option in iView tray or Webdynpro Personalization.
    You don't need to open each iview to change a common property. You can use Multiple Property replacment to achieve this.
    http://help.sap.com/saphelp_NW70EHP1/helpdata/en/0f/764b87dfb948fcb13fd7695e157892/content.htm
    Regards
    Prashant

  • Access to Stiky context menu ?

    Hi guys,
    is there any way to access to stiky context menu ?
    I want remove the "text style" menu.
    Itried the AVAppRegisterForContextMenuAddition for "Page" and Select, but this is not working on note and other stuff??
    (VC++, sdk 8)

    You mean the contextual menu that is brought up inside of a pop-up note? I don't believe that you can intercept that menu.
    Can you explain why you need to do so?

  • How to run report from context menu using XML Extensions?

    I have found an example how to run SQL command from context menu:
    <items>
    <folder type="TABLE">
    <name>UserDefined ContextMenus</name>
    <item TYPE="TABLE" reloadparent="true">
    <title>Create SYNONYM</title>
    <prompt type="check">
    <label>PUBLIC</label>
    <value>PUBLIC</value>
    </prompt>
    <prompt>
    <label>NEW SYNONYM NAME</label>
    </prompt>
    <sql>
    <![CDATA[CREATE #0# SYNONYM  #1# for "#OBJECT_OWNER#"."#OBJECT_NAME#"]]>
    </sql>
    <help>
    This action create a SYNONYM (optionally public) for the selected table.</help>
    <confirmation>
    <title>Confirmation</title>
    <prompt>SYNONYM "#1#" for "#OBJECT_NAME#" has been created.</prompt>
    </confirmation>
    </item>
    </folder>
    </items>
    </prompt>
    But instead of executing SQL command I need to show result page of report based on SELECT statement.

    Hi dz_r-
    Not sure exactly what you mean by "result page of report", but extensive documentation on the xml schema defining context menu actions is available at the schema location.
    &lt;items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://xmlns.oracle.com/sqldeveloper/3_1/dialogs"
      xmlns="http://xmlns.oracle.com/sqldeveloper/3_1/dialogs">
        &lt;!-- your declarations here -->
    &lt;/items>
    Brian Jeffries
    SQL Developer Team

  • How to change the browser used for Google search from context menu of selected text?

    How to change the browser used for Google search from context menu of selected text?
    It uses Safari. But I want to use Chrome (it's my default browser).

    How to change the browser used for Google search from context menu of selected text?
    It uses Safari. But I want to use Chrome (it's my default browser).

  • How to avoid the dialogue when converting from context menu

    This is a follow-up to http://forums.adobe.com/message/2016146#443364 which was locked due to a bug.
    i would like to know how i can avoid the 'save as' dialogue when using the context menu to convert a word file to pdf using windows XP/acrobat 8/word 2007.
    so far, it always prompts me for the filename, which is annoying as it does not allow me to batch-convert several files and let the thing run its course.
    the solution provided by Steve in the other thread does not work - even if the plugin from word does not propt for a filename, it still does when triggered from explorer/context menu.
    so back to square one: how to avoid that dialogue when not opening word at all?
    cheers, thanks for any help. michael

    For a permanent change, START>PRINTERS>right click on Adobe PDF printer and select properties>General>Printing Preferences>Adobe PDF Settings. Under the settings tab, uncheck the box related to asking for a name. Pretty sure that is the location, but it may vary with version.

  • Print from context menu don't resize document

    I have a problem on Acrobat Reader X (but the same problem exists on reader from version 9).
    I have a pdf file with image inside, page size A3, when click print on context menu (right click on the file), the document is send to print, but it's not resize and the image is partial draw.
    When I repeat same operation with Reader 8, the document is print correct.
    Any idea?

    check if this helps
    http://forums.adobe.com/thread/785569

  • New Bitmap missing from context menu after installing photoshop

    After installing photoshop CS6 from CD onto Windows 7x64; my context menu > New > bitmap is no longer available.  registry settings are intact and I've used Bridge ro reassociate .bmp with mspaint but the option still does not appear.  The installation of photoshop is the only change to the computer in several months.
    I can workaround by creating new txt files and changing the extension but this adds a step to a (non photoshop related) workflow that's been in place and worked well for years.

    I don't know why Photoshop would kill the system default entry for new bitmap - possibly because it has associated itself with that file type.
    First thing to look at - start Adobe Bridge CS6, go into the Edit - Preferences - File Type Associations dialog, and see if you can re-associate MSPAINT.EXE with the BMP format.  That may correct the issue, but I can't say for certain as I don't want to try it here and change my own setup.
    I don't use the New context menu functionality for making new bitmaps myself, but when I looked to see what shows up in my New context menu, I found this:
    Choosing the IrfanView BMP File entry led to this:
    If you can't recover the old functionality via the Bridge settings, it may be that you can install the freeware viewer IrfanView and have it associate itself with the BMP file type.
    -Noel

  • How to remove multiple Unarchivers from Context menu

    Hi,
    I am running Mountain Lion on a late 2011 MBP. Every time I upgrade Unarchiver, it creates a new line item in the context menu. How can I get rid of all but the latest one and how can I prevent this from happening? This seems to be a problem with Unarchiver only, the other Apps don't have this issue. Screenshot attached for reference.
    Thanks in advance for your time.
    Abhijit

    That's LaunchServices. These are only cache files but can get corrupted. Launch /Utilities/Terminal and copy & paste this at the command line to rebuild LaunchServices: (be sure to copy the entire line it's a scroll)
    Code:
    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user
    Then press return. Wait until terminal returns to the command line. Quit Terminal. After that, log out and back in or restart. Let us know.
    Or, use the free utiltiy OnyX to do the same via gui
    EDIT: Actually the issue may be with the way unarchiver code is written and LauchServices is doing it's job correctly. But it can't hurt to see.

  • How to remove "Save as PDF" from context menu

    The item "Save as PDF" leads to a commercial site called NITRO. I am trying to eliminate it from the context menu. I installed the add-on Menu Edit and changed the item Save as PDF from visible to hidden on my Windows 8.1 PC with Firefox 30. However, the item did not disappear from the context menu. Yet on my PC with Linux Mint 17 with Firefox 30 for Linux Mint the item is gone from the context menu. My PC s linked with Firefox Synch.
    How can I remove this?

    Such an entry in the context menu is likely added by a PDF related extension, so check your extensions.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem.
    *Switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance
    *Do NOT click the Reset button on the Safe Mode start window
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How to remove upload option from context menu

    Hi all,
    I have a requirment where i need to remove the upload option from the context menu,I tried searching in consumerExploror layout set but dint find where exactly it isavailable.Please help me if u know where exactly it is available.
    Regards
    sharan

    Hi Sai
    Please check these links
    [link2|http://help.sap.com/saphelp_nw04/helpdata/en/75/e000861cb8ad4b8e4f19dd6416346d/framese]
    [link1|http://help.sap.com/saphelp_nw04/helpdata/en/3d/51812c9ba14f4fa104fe3971d5507b]
    i hope this resolves your issue.
    Regards
    Piyush
    pl reward points if this helps.

  • Difference between RRI Command and GOTO from context menu

    Can someone explain the difference between the RRI Command and the GOTO from the context menu?
    Thanks.
    Ryan

    Hi,
    Check this link:
    http://help.sap.com/saphelp_nw04s/helpdata/en/81/941139a772b30de10000000a11405a/frameset.htm
    Hope this helps................
    Rgs,
    I.R.K

  • Remove wine trash from context menu

    If I right-click on most files in linux, there is all kinds of wine options there that I do not want. Namely, notepad (2 instances), Internet Explorer, etc.
    How do I get rid of it without uninstalling wine? I am using XFCE with PCMANFM as desktop manager.

    I know the feeling, bro. It's like Wine crapped all over my system too.
    In Dolphin, for .txt files, I have TWO "notepad" entries!
    Even for avi and mkv files I have a "notepad" entry in there (not by default, obviously). What the hell.
    .jpg files have a "Wine Internet Explorer" entry but .html files don't? Unbelievable...
    Too bad pacman doesn't delete their config files when you uninstall programs. Because I got rid of Wine a long, long time ago and I just couldn't be bothered to search how clean up the context menu leftovers. Hmph. It's about time I reinstalled Arch anyway (switching to x86_64). Now I know not to install Wine ever, EVER again. VirtualBox all the way, baby!
    Last edited by DSpider (2012-02-17 20:06:19)

Maybe you are looking for