DOM Element from a Text frame?

Hi.
In CS2 I used to get an IDOMElement from an ITextFrame. Now that ITextFrame is removed, I'm don't know how to get a equivalent IDOMElement since neither IMultiColumnTextFrame nor ITextFrameColumn aggregate IDOMElement.
Any hints?

Hi Tracey,
It turned out to be really simple: you can translate between text locations and element locations using two methods (one for each direction).
var oTRange = oDoc.TextSelection;
var oTLoc = oTRange.beg;                    /* beg and end are two TLoc objects, which will be the same
                                                                   if no text is selected */
var oELoc = oDoc.TextLocToElementLoc( TLoc );
Kind regards
Jang

Similar Messages

  • [AS] Applescript - Duplicate paragraph from one text frame to end of second text frame?

    Working in InDesign CS5
    Still banging my head against the wall over this last bit of code I need to figure out to finish a much larger script. What I'm looking to do is take a paragraph ('contents' from looping in larger script) from one text frame and duplicate it to the END of a second text frame (represented by 'Ad_Box'). The only thing I've gotten to semi-work is this:
    set insertion point -1 of Ad_Box to contents
    The problems with the above script are:
    1. Minor problem (can be worked around in InDesign CS5) - The script does not keep the formatting from the original paragraph that I want duplicated. The paragraph style of all "inserted" paragraphs is set to default
    2. The big problem - When the second text frame is too small for a particular word in original paragraph, the paragraph is moved to the wrong position in the text frame when the script completes, which is moving 4 paragraphs in total (this one baffles me). In other words, if I'm running script to be p1, p2, p3, p4 and p2 had a word too long to fit in text frame, on completion it will look like p1, p3, p4, p2.
    This is why I'm hoping to use the DUPLICATE command in some capacity, but I'm stumped. I set up a dialogue prompt to help me debug, and whenever I use the DUPLICATE command my script skips right over the dialogue, so I know it's not reading properly. This is what I've tried with no luck. Any help would be greatly appreciated.
      duplicate contents to insertion point -1 of Ad_Box

    Mary, you were absolutely correct!! This fixes the problem of placing the contents into the wrong spot, AND it runs the script much faster too! Thank you.
    However it is still not carrying over my "applied paragraph style" that is on "contents". Does 'insertion point' not work this way?
    What looks like is happening is that in the InDesign app, whatever my default selected paragraph style is is what the insertion point type is placing as.
    I might try to set my applied paragraph style after the "last insertion point" call and see if that works. I'll update this reporting results

  • How to copy a table from one text frame to another...

    Is there a way to copy a table from one text frame to another? I'm using JavaScript. The following will move a table from one text frame to another, but I need to copy.
    var srcFrame = document.textFrames.item("section-template");
    var dstFrame = document.textFrames.item("test");
    srcFrame.characters[0].move(LocationOptions.before, dstFrame.insertionPoints[0]);
    Thanks,
    Mike-

    Hi Bhupinder,
    According to your description, you want to copy a table with Primary keys from one database to another database.
    As per my understanding, I think the best method is use Transfer SQL Server Objects Task in SQL Server Integration Services. The Transfer SQL Server Objects task transfers one or more types of objects in a SQL Server database between instances of SQL Server.
    Server roles, roles, and users from the specified database can be copied, as well as the permissions for the transferred objects. Indexes, Triggers, Full-text indexes, Primary keys, Foreign keys can also be copied.
    To use the Transfer SQL Server Objects Task, we should create a SQL Server Integration Services Project in SQL Server Data Tools, then drag a Transfer SQL Server Objects Task to Control Flow pane. Specify SourceConnection, SourceDatabase, DestinationConnection
    and DestinationDatabase for the Connection, select the table in the ObjectsToCopy category, then change CopyPrimaryKeys to True and the other corresponding properties in the task.
    References:
    Transfer SQL Server Objects Task
    Transfer SQL Server Objects Task in SSIS 2008 R2 With Example
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Text disappearing from CS4 text frame.

    I work in a studio environment with multiple computers/users sharing files from the same server. Occassionally when I (or another user) opens an InDesign CS4 file there will be text missing from one or more text frames. The frame is still there, but it is empty. If I close the file without saving and then re-open it, the text may re-appear in that frame, but text may be missing from a different frame, or no text will be missing at all – seemingly a completely random occurrance. We have tried to resolve whether this happens with missing/conflicting fonts, but there seems to be no correlation. The problem is not repeatable, but happens at least once a month. We cannot narrow down any ther common denominators within the files.
    We run Mac Pros and iMacs, OS X 10.5.8 or later, InDesign Creative Suite 4, Suitcase Fusion 2 and we are running a Windows Server (sorry, no other details on that).
    Any help or suggestions would be appreciated.

    Thanks for the advice, folks.
    I have hidden text enabled and there is nothing in the frame. These are standalone frames – not linked to any other frames, so it wouldn’t seem to be a re-flow issue. My gut is telling me that it’s font-related, as we have MANY font conflicts between computers, however the issue sometimes occurs without the “Missing Fonts” alert appearing upon opening.
    Suitcase Fusion 2… Unfortunately that may be the culprit. Yet another reason to not like that product, unfortunately. I will research that line of reasoning and report back.

  • Import (and export) HTML text into a text frame (CS2)

    Hi
    As I know it is not possible to import or export text in or from a text frame in HTML format directly.
    - Is there a way to do that?
    - If yes how can I do that? A piece of sample code would be great...
    - Actually I use this for Indesign CS2. Is the HTML import / export in CS3 possible?
    Thanks for the help
    Greetz
    Hans

    Yup. There's no HTML parser built into InDesign.
    Actually, GREP is not a great way to go about it. How would you handle nested tags with GREP? A state machine is a much better way to parse HTML. You might want to look around for Javascript parsers.
    Rorohiko has an HTML walker. I'm not sure if it would help you or not.

  • 1 XML node to many Text Frames

    In indesign is it possible to map the content of a single XML node element to multiple text frames within an Indesign document?
    I have data elements in my XML that I don't want to repeat but they have to appear in multiple places within my document.
    Is this possible? What's the trick?
    Thanks,
    Gordon

    I don't have it to test with, but might the Linked Stories feature in CS5.5 allow you to do this? Maybe that's worth a look. I don't know of a way to do it in CS5 or before.
    Jeff

  • CS4 editable master text frames in CS5 no longer editable

    Hi,
    Problem: Text frames on CS4 document pages (from locked text frames on masterpage) are no longer editable on CS5 document pages.
    CS4 situation:
    Masterpages contain text frames which are locked to prevent users from inadvertently moving them when working on document pages.
    On document pages, the text frames can be edited, i.e. text entered, but are position-locked.
    CS5 problem:
    When you now open the same document, the text frames on the document pages are totally locked, the positioning as well as the content. This means they are no longer editable! The only way I have found to make them editable once again is to unlock the text frames. But unlocking also removes the position lock.
    What do I have to do to get things working in CS5 like they were in CS4? Any quick solution or is this simply no longer possible?
    Confounded by InDesign once again...

    Yes, it works just like in CS4! Wunderbar!
    As I just had some trouble finding the where to change this setting,
    for anyone working with the German version of InDesign CS5:
    Menü: Bearbeiten > Voreinstellungen > Allgemein
    then under "Objektbearbeitung", remove the checkmark from "Auswahl von gesperrten Objekten verhindern"
    Thanks!

  • How do I create a series of text frames using values from Excel list?

    First of all, this is the very first script I'm attempting to write from scratch. I'm completely green at scripting, and I've picked up a few snippets from Adobe's ID scripting guide, but nothing has really stuck yet relating to this particular objective.
    My supervisor keeps a master list of ad spaces, with the name of the account, how wide the space is, and how tall the space is, all in an Excel sheet. These spaces can number in the hundreds, and I am stuck manually drawing one rectangle for every space, which takes a very long time.
    I'd like to create/have help creating a script that will take these values and "automagically" draw these spaces in the form of text frames, with the width (in columns) and the height (in inches) defined by the values in the master list, as well as the name of each account appearing in the subsequent text frames.
    The script doesn't necessarily need to be able to pull the values straight from the Excel sheet; I can transfer the values to a support text file if needed, or directly into the script, changing it as I need it. A big thing (if it is not able to pull right from an Excel sheet) is that the number of spaces changes weekly, and so do the accounts, and the width and the height. Accordingly, it would be ideal if the values from the sheet could be changed easily, so as to create a new set of spaces as needed.
    Positioning for each space is not crucial, only height and width. If they all appear on top of each other on the same page, that will be a result for me. The main idea is to not have to draw them all manually, one by one.
    To me, this sounds like a tall order, but hopefully some experienced scripters out there can assist me, as I wish to become experienced as well.
    So, the TL;DR version:
    - Script needs to draw a series of text frames.
    - Text frames dimensions need to be defined by width and height values from Excel sheet.
    - Text frames must have account name as contents (from account names in Excel sheet).
    - Accounts, width and height change every week in the Excel sheet, so must be relatively easy to exchange all of the values.
    - The width values are on the Excel sheet as columns. It would be ideal if the script could convert those numbers into multiples of columns as needed.
    - (Optional) Script can pull values directly from Excel sheet.
    - (Optional) Script can define text frame fill color as gray. (If it works as I think it will, I could just select all the resulting text frames myself and set them all to gray at once... I'm not that lazy )
    Thanks in advance to whomever can assist in any possible way, even if it is just a push in the right direction. This script will save 1-2 hours of tedium every week.

    Sound like the perfect thing for InDesign Scripting.
    I would copy the Excel contents into a text file, to get a format that is easily read from InDesign, and there will automatically be a TAB for each "cell" just using copy/paste.
    Here is a piece of code, that you perhaps could go on with (adding variable to change pages and location on page, and other stuff).
    The readFileLineByLine function, can be easily re-used with any function using "callback". You simply supply the function to it, that you want to be executed for every line of text that is read:
    const COLUMN_WIDTH = 2; // Define the column width in inch
    var pageIndex;
    var textFramesExported; // not implemented.
    // Add a new dokument. Set myDoc to app.activeDocument to use
    // the current document instead of creating a new one.
    var myDoc = app.documents.add();
    // The doSomethingWithTextRow function is called upon for every line of text read.
    readFileLineByLine('c:\\test.txt', doSomethingWithTextRow);
    function doSomethingWithTextRow(row){
        // We expect the text line to be TAB separated (\t = TAB). We get that from just copying the contents of an
        // excel file into a text document.
        var cells = row.split('\t');
        var companyName = cells[0]; // The Company name in the first slot of the array
        var width = COLUMN_WIDTH * cells[1];
        var height = cells[2];
        // Create a new text frame for every row handled
        if (pageIndex==undefined) pageIndex = 0; // Count up when you have exported a number of texts, I leave this for you to do.
        var newTextFrame = myDoc.pages[pageIndex].textFrames.add();
        newTextFrame.contents = companyName;
        // The text frame is created in the top left corner.
        newTextFrame.geometricBounds = [0, 0, height + ' in', width + ' in']; // Top, Left, Bottom, Right
        // You might want to move the textframes to other positions, keeping track of how many you put out per page.
        newTextFrame.move( [10, 10] );
    function readFileLineByLine(path, callbackFn){
        var myFileIn = new File(path);
        if (File.fs == 'Windows'){
            // This was probably added to recognize UTF-8 (even without its start marker?)
            myFileIn.encoding = 'UTF-8';
        myFileIn.open('r');
        var myEncoding = myFileIn.encoding;
        try{
            if (!myFileIn.exists){
                throw('Missing file: ' + myFileIn.fsName)
            var ln = '';
            while(!myFileIn.eof){
                // Read the lines from the file, until an empty line is found [now as a remark].
                ln = myFileIn.readln()
                // if(ln !='' && ln!='\n'){
                   // Call the function supplied as argument
                   callbackFn(ln);
        }catch(e){
            alert(e);
            gCancel = true;
        finally{
            myFileIn.close();
    The file in C:\ in my example was saved as UTF-8 and looks like this (showing hidden characters):
    Message was edited by: Andreas Jansson

  • Invoking BPEL process from Java servlet with org.w3c.dom.Element as payload

    Hello,
    I'm trying to initiate a BPEL process from my servlet running under Tomcat. When I create the NormalizedMessage passing the XML as a String everything works fine. But if I use an org.w3c.domElement the BPEL server doesn't react at all (even on DEBUG log level there are no outputs).
    This works:
    NormalizedMessage message = new NormalizedMessage();
    message.addPart("payload", "<foo></foo>");
    This doesn't work:
    org.w3c.dom.Element elem;
    oracle.xml.parser.v2.XMLDocument xmlDocument;
    NormalizedMessage message = new NormalizedMessage();
    Element elem = xmlDocument.createElement("foo");
    message.addPart("payload", elem);
    Is there a known problem with payloads using Element or did I get something completely wrong? Thanks in advance,
    Hans.

    Hello,
    I'm trying to initiate a BPEL process from my servlet running under Tomcat. When I create the NormalizedMessage passing the XML as a String everything works fine. But if I use an org.w3c.domElement the BPEL server doesn't react at all (even on DEBUG log level there are no outputs).
    This works:
    NormalizedMessage message = new NormalizedMessage();
    message.addPart("payload", "<foo></foo>");
    This doesn't work:
    org.w3c.dom.Element elem;
    oracle.xml.parser.v2.XMLDocument xmlDocument;
    NormalizedMessage message = new NormalizedMessage();
    Element elem = xmlDocument.createElement("foo");
    message.addPart("payload", elem);
    Is there a known problem with payloads using Element or did I get something completely wrong? Thanks in advance,
    Hans.

  • How do I create a series of text frames from a list of files?

    And I'm back again.
    This time, I'm wondering how I can use JavaScript to place a series of text frames from a list of files, preferably with the ability to specify criteria before running the script.
    Here's the details: I work for a newspaper and I lay out stories for the pages (in addition to the other part of my job, laying out ad spaces, as detailed in a previous thread, for which I requested another script, thanks Andreas and Jongware ). The file names for the stories are labeled for the section they go in, like L- for Life, C- for Comment, S- for Sports, etc.
    I'd like to create a script that asks for a criteria in a text box (where I can type L-, C-, S- or whatever else I need) and then places all of the stories, in a specified directory, whose file names match what was typed in the box, one text frame for each.
    I can't rightly tell if this is a simpler or more difficult script to write out, but I plan on putting research into it as usual so I can develop it myself. However, I figured it would be more efficient to ask first, then research, so that while I'm researching, I can refer to the opinions of my fellow forumites, and/or the mods.
    Thanks again for any assistance offered.

    And I'm back again.
    This time, I'm wondering how I can use JavaScript to place a series of text frames from a list of files, preferably with the ability to specify criteria before running the script.
    Here's the details: I work for a newspaper and I lay out stories for the pages (in addition to the other part of my job, laying out ad spaces, as detailed in a previous thread, for which I requested another script, thanks Andreas and Jongware ). The file names for the stories are labeled for the section they go in, like L- for Life, C- for Comment, S- for Sports, etc.
    I'd like to create a script that asks for a criteria in a text box (where I can type L-, C-, S- or whatever else I need) and then places all of the stories, in a specified directory, whose file names match what was typed in the box, one text frame for each.
    I can't rightly tell if this is a simpler or more difficult script to write out, but I plan on putting research into it as usual so I can develop it myself. However, I figured it would be more efficient to ask first, then research, so that while I'm researching, I can refer to the opinions of my fellow forumites, and/or the mods.
    Thanks again for any assistance offered.

  • Name Exported PDFs with a filename generated from text frame on page

    Does anyone have an idea how to do the following? We are on InDesign CS5 on a Mac running OSX 10.6
    We are plan on creating a document of say 100 pages. On each page will be a photo of a product and some text frames. In one of the frames will be the product's SKU code - which we will enter manually.
    What I want is that we can then export each page as a separate PDF and the filename of each PDF will be taken from the SKU code present in the text frame with .pdf appended.
    Has anyone done something like this?
    Thanks

    Ask in the Scripting forum... InDesign Scripting

  • Delete elements from XML file using DOM and java

    Hi
    I want now is to remove element from my XML file
    for example
    i have following xml
    <?xml version="1.0" encoding="UTF-8"?>
    <printing>
    <firstLineTexts>
              <firstLineText />
              <firstLineText>|line11</firstLineText>
              <firstLineText>|line12</firstLineText>
    </firstLineTexts>
    </printing>how do i remove all elements fireLineText
    my final output should be
    <?xml version="1.0" encoding="UTF-8"?>
    <printing>
    <firstLineTexts>
    </firstLineTexts>
    </printing>How do i do it using DOM,
    I can create instance of DOM and write it using TransformerFactory
    Ashish

    Hi
    I am trying the following code,
    but it is not working
                    NodeList nScene = doc.getElementsByTagName("firstLineTexts");
              NodeList nScene1 = nScene.item(0).getChildNodes();
              for (int i = 0; i < nScene1.getLength(); i++)
                   Node n = nScene1.item(i);
                        nScene.item(0).removeChild(n);
              }

  • Remove element from xml using dom.

    i want to remove an element from an xml file using dom.
    i remove the element but the whole content of the file is also deleted.
    how can i rewrite the file.

    vij_ay wrote:
    subject :Remove element from xml,but if empty element in input file then output should be <tag></tag>, not like <tag.xml/>I assume you mean <tag/> but why do you want this? Any application that will not accept this valid XML construct is flawed and a bug report should be raised against it.

  • How to map more than one xml element with some Paragraph in a Text Frame

    Hi friends,
    I am new in InDesign Java Scripting and I have to place or map, more than one xml elements of different parents, into one textbox. Is it possible through JavaScript? Can anyone help me in this because I have no idea how it should work and it urgently required.
    Thanks in Advance

    I had answered to you already in your first post: the short answer is that it's not possible on the same text box unless you assign a common ancestor of these two "parents" item. That's not a question of scripting, it's the way Indesign handle the XML with the layout. Import a xml in Indesign and drop tags to page item. What you can do manually is quite representative of what can be done through scripting.
    If you assign this anscestor to the text frame, you have to expect that all text child items will be displayed in the text frame (including the text of all the child of the two "parents" and all the other parents/childs that could be under the common ancestor). Having a XML that is designed for Indesign usage is pretty much inevitable if you are doing anything "serious".

  • Copy text frames and paste in place from source file to opened docs

    Hello All,
    I have one source indd file which is having 10 small text frames (40pt square) in both pages (Facing pages, Left and Right) on a master page. In that master page there is no frame except that 10 small text frames and the text frame contains the paragraph style called "Cat_Cont".
    I have opened some files and I want to copy that 10 small text frames from the source file and paste in place into the opened InDesign Docs master pages. I hope while copying that text frames, paragraph style also would copy. Could anyone help for this, please?
    If anything not clear plz let me know.
    Thanks in Advance,
    Thiru

    Use TextFrame.duplicate()

Maybe you are looking for