Change X, Y position of a text frame based on some conditions

Hi All,
I am trying to re-position the Y position alone of all text frames in a documennt if that text frame has certain Y position. Here is the code I tried.
It works, but, it place all the text frames in to the given myTextFrame.move ( ["216.425 pt","54 pt"] ); one on another. Whereas, I need to change Y position of only the text frames with the following conditions.
The conditions are:
If X="216.425 pt" AND Y="103.89 pt", change to X="216.425 pt" and Y="54 pt"   OR
If X="216.425 pt" AND Y="78.945 pt", change to X="216.425 pt" and Y="54 pt"    OR
If X="216.425 pt" AND Y="79.157 pt", change to X="216.425 pt" and Y="54 pt"    OR
If X="213.425 pt" AND Y="486.647 pt", change to X="216.425 pt" and Y="54 pt"    OR
If X="213.425 pt" AND Y="74.409 pt", change to X="216.425 pt" and Y="54 pt"   
Please help me on this to add the above conditions into the following code and reposition only the text frames has the above said XY positions.  Is there anyother way other than "move" statement?
var myDocument=app.activeDocument;
var myPages=myDocument.pages;
    for(p=0;p<myPages.length;p++) {
    var allTextFrames=myPages[p].textFrames;
        for (s=0; s<allTextFrames.length; s++) {
                    var myTextFrame = allTextFrames[s];
                    var myTextFrameBounds =  myTextFrame.geometricBounds;
                    var properly_aligned = "54 pt";
                        if ((myTextFrameBounds[0] = "103.89 pt") && (myTextFrameBounds[1] ="216.425 pt")) {
                            myTextFrame.move ( ["216.425 pt","54 pt"] );

Hi Jongware,
Thanks for your reply.
I have modified the code little bit after referring one of the post. Here is the updated code. It is working fine for the whole number (var oldposition1) as input value and does not work for decimal values (var oldposition2, var oldposition3, var oldposition4 and var oldposition5). However, it repositions the frames with decimal values (newposition1, newposition2 and newposition3). I am facing problem with the decimal input values for original position of text frames. Is there any other way to give decimal values as input as my document comes with these decimal values as X, Y position.
var oldposition1 = [216, 103] // original position, upper left corner
var oldposition2 = [216.425, 78.945] // original position, upper left corner
var oldposition3 = [216.425, 79.157] // original position, upper left corner
var oldposition4 = [213.425, 74.409] // original position, upper left corner
var oldposition5 = [213.425, 486.647] // original position, upper left corner
var newposition1 = [216.425, 54] // new position, upper left corner
var newposition2 = [36, 54] // new position, upper left corner
var newposition3 = [216.425, 437.4] // new position, upper left corner
var myObjects = app.activeDocument.pageItems.everyItem().getElements();
for (var i=0; i<myObjects.length; i++){
    if (Math.round(myObjects[i].geometricBounds[1])==oldposition1[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition1[1]){
        myObjects[i].move(newposition1);
    else if (Math.round(myObjects[i].geometricBounds[1])==oldposition2[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition2[1]){
        myObjects[i].move(newposition1);
    else if (Math.round(myObjects[i].geometricBounds[1])==oldposition3[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition3[1]){
        myObjects[i].move(newposition1);
    else if (Math.round(myObjects[i].geometricBounds[1])==oldposition4[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition4[1]){
        myObjects[i].move(newposition1);
    else if (Math.round(myObjects[i].geometricBounds[1])==oldposition5[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition5[1]){
        myObjects[i].move(newposition3);

Similar Messages

  • Changing Label text color based on some conditions

    Hi,
    I have these labels and I would like to change the text color IF the text has some specific value (coming from an XML created by a program); for example the default text color is red, but if the text value is "Yes", the text color should be green.
    Any helps much appreciatted, as usual...
    Thanks.

    unsure, but you might be able to get away with something like this:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Script>
            <![CDATA[
                public function changeColor(value:String):uint
                    if(value == "Yes")
                        return 0x007F00;
                    else
                        return 0x7F0000;
            ]]>
        </mx:Script>
        <mx:Panel x="343" y="199" width="250" height="200" layout="absolute">
            <mx:Label id="lbl1" text="Yes" color="{changeColor(lbl1.text)}" x="102.5" y="10"/>
            <mx:Label id="lbl2" text="BlahhhhhBlahhhh" color="{changeColor(lbl2.text)}" x="97" y="36"/>
            <mx:Label id="lbl3" text="Exampleeeeeeee"  color="{changeColor(lbl3.text)}" x="97" y="62"/>
        </mx:Panel>
    </mx:Application>
    using a single label in an item renderer, passing across the 'data.text' value

  • Global change to the size of a text frame in InDesign 5.5?

    Is there a way to make a global change to the size of a text frame in InDesign 5.5? I just laid out a book and the size needs to go up half an inch.

    If you have worked properly and have done following:
    Set up Masters with margins and columns,
    Aligned all text frames with the margins,
    Turned on Layout Adjustment,
    You will only change the margins on the Master and it will change every page.
    If not …
    you have to do it manually.

  • How to re-size a overflow text frame based on the text length?

    Hi ..
    Is it possible to re-size a overflow text frame based on the text length?

    Hello,
    Please refer to forum post : http://forums.adobe.com/message/4828489#4828489
    Regards,
    Sachin

  • Display Image(which set as behind text)   based on some condition.

    hi all
    I have developed a xml report and in that rtf am displaying a static image (which is set as behin text).
    But i need to display the image based on some condition
    for example i have a field as ORG_ID
    if org_id=87 then image should display for that purpose am planning to use <?if:ORG_ID=87?> condition but where to place this condition for the image.
    kindly help me
    thanks for all in advance.

    that too not working because
    on image am displaying some other fields.
    see i think you didn't get my point.
    in my out put page am displaying item details ,quantity,and cost and customer details just like invoice copy .
    behind this data am displaying my company logo which will capture whole page size..
    if i place the image in table then fields will be automatically in table so i cant restrict image in this way.
    Kindly suggest any other way that works only for image which is behind text. i mean condition should be applicable only for image and leaving all other fileds in rtf.
    or
    help on this how to set a dynamic image as behind the text.
    Edited by: maddy on Nov 28, 2012 7:32 AM
    Edited by: maddy on Nov 28, 2012 7:35 AM

  • [JS][CS3] Change the content type of a text frame

    Hi,
    a bit basic maybe but I'm stuck on this from an hour...
    I need a textFrame to become a graphic object.
    The textFrame has no content.
    How can I change the contentType on that object?
    Thanks anticipately.

    This looked like an interesting challenge, so I'm taking a shot at it. I created a new document and added three text frames (unpopulated) to the first page. I tagged them "Image", "Caption" and "credit". I then exported as a snippet, deleted the document and opened another new one. Then I placed the snippet (so far, everything has been manual -- no scripts) and indeed, the snippet placed and the frames were added to the document's structure and were properly tagged -- the three tags were automatically created by the action of placing the snippet.
    So, let's duplicate this in a script. Even though I know exactly where the snippet is, I'm going ask the user to find it. That way, I eliminate the issue of getting the path to the snippet wrong:
    var myDoc = app.documents.add();
    var myPage = myDoc.pages[0];
    var myPlacePoint = [myPage.marginPreferences.left, myPage.marginPreferences.top];
    var mySnippetFile = File.openDialog("Choose the snippet");
    if (mySnippetFile == null) { exit() }
    var mySnippet = myPage.place(mySnippetFile, myPlacePoint);
    And that worked. The snippet is on the page exactly where I wanted it. So, now we need to find the text frame that has the "image" tag. First, we must explore just what mySnippet consists of.
    OK, it's an array of three stories. That's a tad weird. Why isn't it an array of three text frames? I wonder what would happen if two of the frames in the snippet were threaded -- but let's address that later after we solve the immediate issue. The point is that we know that the snippet consists of three separate text frames that aren't threaded. So:
    for (var j = mySnippet.length - 1; j >= 0; j--) {
         var myTag = mySnippet[j].associatedXMLElement.markupTag.name;
         alert(myTag);
    And this gives me the three tags (and reminds us that when you tag a text frame you're also tagging the story that holds it. So:
    var myDoc = app.documents.add();
    var myPage = myDoc.pages[0];
    var myPlacePoint = [myPage.marginPreferences.left, myPage.marginPreferences.top];
    var mySnippetFile = File.openDialog("Choose the snippet");
    if (mySnippetFile == null) { exit() }
    var mySnippet = myPage.place(mySnippetFile, myPlacePoint);
    for (var j = mySnippet.length - 1; j >= 0; j--) {
         var myTag = mySnippet[j].associatedXMLElement.markupTag.name;
         if (myTag === "Image") {
              var myFrame = mySnippet[j].textContainers[0];
              myFrame.contentType = ContentType.graphicType;
              break;
    And that does the job.
    Thomas,
    You were very close but you forgot that the text frames that make up a story are addressed as textContainers from CS3 onwards. Your code would have worked in CS2.
    Dave

  • Dynamic Action - How to enable  text field based on a condition

    Hi,
    I have two text items. Need to create dynamic action for the following,
    1. Order_type - Drop down values having CONSUMER & WHOLESALE.
    2. Order_number- Text field
    Order number should be disabled and only on selection of order type ,order number should be enabled.
    Can someone please help me on this?

    Hi Gayathri,
    Gayathri Venugopal wrote:
    Hi,
    I have two text items. Need to create dynamic action for the following,
    1. Order_type - Drop down values having CONSUMER & WHOLESALE.
    2. Order_number- Text field
    Order number should be disabled and only on selection of order type ,order number should be enabled.
    Can someone please help me on this?
    Create two dynamic action
    1. Make it order number item disable on page load.
       Event : Page Load
       Action : Disable
       Fire When event result is : True
       Selection Type : Item
       Item : Your order number item
    2 . enable and disable order number on selection of order type(assuming when order type is null it is disable otherwise it is enable)
        Event : Change
        Selection type : item
        Item : your order type item
        condition : is not null
    True Action
        Action : Enable
        Fire When event result is : True
        Fire on page load : True
        Selection Type : Item
        Item : Your order number item
    False Action
        Action : Disable
        Fire When event result is : False
        Fire on page load : True
        Selection Type : Item
        Item : Your order number item
    Hope this helps you,
    Regards,
    Jitendra

  • How to change the insert allowed false dynamically based on some condition

    Hi,
    I have two data blcoks B1 and B2.
    B1 is heade and B2 is detail.
    B1 contain one filed PO number based on that user press the button.
    Based on PO we get the some fileds in B2 from cursor.
    In B2 filed contain total 5 fields. 4 fields come from cursor button. remaining one field user will enter.
    My requirement is afte the getting the records from cursor. I need to not allowed to create new records.
    Please do the needful.

    902434 wrote:
    Hi,
    I have two data blcoks B1 and B2.
    B1 is heade and B2 is detail.
    B1 contain one filed PO number based on that user press the button.
    Based on PO we get the some fileds in B2 from cursor.
    In B2 filed contain total 5 fields. 4 fields come from cursor button. remaining one field user will enter.
    My requirement is afte the getting the records from cursor. I need to not allowed to create new records.
    Please do the needful.As per i understand you want on block b2 insert allowed false.
    Try this
    If your_condition then
         SET_BLOCK_PROPERTY('block_name', INSERT_ALLOWED, PROPERTY_FALSE);
    else
         SET_BLOCK_PROPERTY('block_name', INSERT_ALLOWED, PROPERTY_TRUE);
    end if;Hopes this helps..

  • [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

  • Each time I create a Text Frame it appears colored with black?

    Every time I create a Text Frame with the Type tool in InDesing CS5.5 in a document named "02_End.indd", (this happen only for this file) the it appears filled with black color. On the other documents this does not happen (the text frames are with no fill).
    Can anyone tell me how can I change the default color of the Text frames?
    Please help me?

    Make sure you don't have anything selected. Then look in the swatches palette. If you see the default fill is black, set it to [None].
    If not, it may be your default object style, or possibly a document corruption -- if you suspect the latter, you could try to Remove Document Corruption as per the instructions at the top of this forum.

  • Select each page's text frame in one shot and resize them

    Hello, I want to make a 400 page text book. How can I select each page's text frame in one shot and change their size simultaneusly? (each text frame has same size per page)

    Make a backup copy of the file incase something goes wrong, then:
    Make sure the frames snap to the margins on all sides -- change the margins on the applied master page to achieve this, if necessary.
    Enable Layout Adjustment (Layout > Layout Adjustment...)
    On the master page change the margins to be the size you want the new text frame dimensions to be.
    If, for some strange reason, you don't want to use these margin settings in the layout, turn OFF layout adjustment and reset them on the master page again to what you want.

  • Centering text frame into rectangle

    Hi everybody, i'm pretty a new-by with indesign so be kind with me
    I was trying to center "2 objects": actually, a text frame inside a colored rectangles. My goal is to have the frame containing the text exactly centered into the main rectangle.
    As you can see i'd like to be able to center the text frame "Address" into the big cyan rectangle. I could do it manually but the result would be different from the rest of the text frame i have to center (date of birth...and so on).
    Thanks for your help people!

    Also keep in mind that whether you use two objects (text frame and colored box) or one text frame like Peter suggested, the positioning of the text is based on the full size of the font, which is measured from the lowest descender to the highest ascender. So, a box with an upper case A and one with a lower case j will have different distances from the top and bottom of the box, so if what you want is an even amount of box around your text, you might have to make an adjustment.
    All boxes are aligned the same, but not visually centered.

  • [JS, CS3] Need help changing tabStop positions of selected text

    Hi all,
    I am writing a script to nudge the tabStop positions of selected text by one point at a time. Sometimes it will be only a tab character selected, and other times it could be several in the paragraph or maybe even the whole story. The problem I am encountering is that when I reference the tabStops as app.selection[0].tabStops it includes ALL the tabStops in the paragraph and NOT just the selected ones. Is there a way to get just the selected tabStops and add a point to their positions? It must be that my referencing is flawed. Thanks for any help.
    Regards,
    Len Swierski

    Hi Len,
    That's not a bad approach, but remember that there may be more tab characters than there are tab stops. I was thinking of getting the location of the selected tab stop relative to the left edge of the text frame (or column, if you're working with multi-column frames) and then comparing it to the location of the tab stop. But I think your approach will work just as well and be quicker.
    Also, remember that when you start moving tab stops around, the index of the tab stop within the tab stops collection can change. If you have tab stop A at 12pt and tab stop B at 16pt, then tab stop A will be item(0) and B will be item (1). But if you move A to 24pt, A will become item(1) and B will be item(0). The index of the tab stop is relative to its location on the tab ruler.
    Thanks,
    Ole

  • Can you change a story or text frame's index? (re autonumbering)

    Does anyone know if there is a way to change the index of a text frame or story without changing the actual visual layout of an InDesign document? So far all I can come up with is to cut the frame and repaste it into the document. You can move a story within the index list of a document, but that visually cuts and pastes the story text.
    actDoc.stories.item(1).move(LocationOptions.BEFORE, actDoc.stories.item(0));
    I can't see any method to change the index of a text frame (other than cutting and repasting).
    I want to put together some tests. I have a bunch of questions. Each question is a single story in a single text frame in an InDesign document. The text frame is linked to an InCopy document. The first paragraph of the question has a "QuestionNumber" style but the para style has no numbering. I want to have only one version of each question (the InCopy story) but to put the questions into different tests in different orders with different numbering. What I do is to create an InDesign template for the tests that has a QuestionNumber para style that includes autonumbering with the "Continue Numbers across Stories" option checked. This works beautifully and the questions are numbered in the order in which the text frames (and stories) are (via a script) copied from the question document and pasted into the test paper document. When the same question/story/textframe is used in two tests it is numbered in the order in which it is pasted into each test paper (but the original stays the same because it has no numbering).
    The next step would be to be able to reorder the question numbers within the test paper (if you wanted to, say, swap questions 18 and 20). To do that you have to change the index of the story because the autonumbering across stories seems to depend on the index of the story.
    What seems to happen is that stories are indexed in the order in which they are pasted into a document, but text frames are indexed in the opposite order. If you paste a text frame with one story into a new document, it is textframe.item(0) and story.item(0). If you then paste a second one into the document it is story.item(1) but textframe.item(0). The first text frame becomes textframe.item(1). When you cut a text frame and repaste it, it is reindexed as if you were pasting it for the first time.
    The autonumbering also seems to be segregated by page. If you have questions 1 and 2 on page 1 and questions 3 and 4 on page 2, you can move around the text frames for 1 and 2 on the page but the numbering stays the same. Likewise for 3 and 4. If you drag 3 across to page 1 it stays as 3 but if you drag question 4 across to page 1 it becomes 3, and the original question 3 on page 2 becomes question 4. It is confusing but makes sense in a weird way once you get the hang of it.
    Anyway, I have probably answered my own question and the best way to renumber the questions in a test is to run the script again and create a new document using a new question order.
    But any other ideas are welcome.
    Thanks.

    hi Brian
    which version of InDesign you have ?
    I have checked these steps on CS3 and CS4:
    first I've set ON to option in preferences to preserve links when placing
    then I've placed DOC file as AnchoredTF in new Story
    then I've copied this AnchoredTF and pasted it on page, and then I've pasted it as another AnchoredTF - each time there was new lick created to the same DOC file
    then I've set OFF to option in preferences to preserve links when placing
    and even when I again copied and pasted this AnchoredTF with placed DOC file - it still add new link on Links palette
    so maybe with InCopy stories there is next bug or next "feature" ...
    [edit]
    ok - I've checked InCopy file - after exporting TextFrame as InCopy Story
    and it's like you've said - pasting on page - new link is created - pasting as Anchored - link isn't created ... no matter if option in preferences is set or not ...
    verdict - we've found new bug
    BUT ... if you link it again - by CTRL+D method - link is preserved even if option in preferences is set to off so you can have more than one InCopy Story placed as AnchoredTF in same parent Story ...
    robin
    www.adobescripts.co.uk

  • Change the position of the text field in the report region

    Hi,
    I am having a report region in whch there are 2 buttons which are in the Region Template position #Create# and a
    text field. I added a text field in the same region. I tried to change the position of the text field near the buttons. I
    tried to change "label-Horizontal/vertical alignment" and "Element horizontal vertical alignment". But the postion of the
    text field is not changing. Plz help,
    Thanks,
    TJ

    Hi Andy,
    Sorry to ask this questions.
    1.Where exactly i need to change the HTML code(By uisng the view source?)
    2.My taskname part html code when viewing the source is given below
    tabindex="999"><img src="/i/e.gif" alt="Edit" class="eLink" />
    </a><tr></td><td nowrap align="left">
    <label for="P1_TASK_NAME" tabindex="999">
    <a class="t16OptionalLabelwithHelp" href="javascript:popupFieldHelp('5853137628393530415','676839962625525')"
    tabindex="999">Task Name</a></label></td>
    <td  colspan="1" rowspan="1" align="left" valign="top"><input type="hidden" name="p_arg_names"
    value="5853137628393530415" /><input type="text" name="p_t06" size="10" maxlength="20" value=""
    id="P1_TASK_NAME"  /><a class="eLink" title="Edit" href="javascript:popupURL('f?
    p=4000:371:676839962625525::::P371_ID,FB_FLOW_ID,FB_FLOW_PAGE_ID:5853137628393530415,107,1');" 
    tabindex="999"><img src="/i/e.gif" alt="Edit" class="eLink" /></a></td></table>
    <table summary="" cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td align="right"><table
    cellpadding="0" cellspacing="0" border="0" summary="" class="t16Button">please suggest what changes i need in this code to change the alignment of the task_name text field,
    Thanks,
    TJ

Maybe you are looking for

  • Query in jdeveloper using  distinct clause

    hello I am a user of oracle10G jdeveloper using jclient/swing in my product. I had written a query in my default view object as Select distinct(Name) from emp then i test it. Then message get displayed Query is valid. But when i bind this view object

  • Using the IF function with a range of numbers

    I am working with the IF function and trying to get it to work "if" the number I'm examining is within a range of numbers. Example: If a wigit costs between $1000 and $1999, then a discount of $100 is given If a wigit costs between $2000 and $2999, t

  • Photoshop album 2.0 mini で3gpファイル取り込めない

    adobe photoshop album 2.0 miniを使用しているのですが.手持ちの3gpp形式のファイルが取り込み時に対象となりません.QTPro6.5はインストール済みです.QTから3gpファイルを作成してみましたが. これも取り込めません. サイトなどを確認しましたが.miniで3gpファイルの利用制限は無いように感じます. なお.MOV形式のQT動画は取り込めます. どなたか3gpp形式の動画ファイルを取り込めた方いらっしゃいますか?

  • Acrobat XI problems in IE 11 including flash

    Having recently purchased and installed Acrobat XI on my Windows 8.1 laptop, several problems occured. First off, I can't open PDFs. IE asks me to allow add-on "AcroPDF.dll". Pressing Allow or Allow on all websites just refreshes the page and reasks

  • Repetition in Bookmarks Bar and Menu Sidebar, shifting in MenuBar,

    I am seeing deleted bookmarks return as well as it seems a neverending growth and repetetion of my bookmarks since 5.1.2 update and numerous repeats in the bookmarks bar and menu. See attached screenshot. Yes, I used MobileMe and have been using iClo