Place text object stored in array
hi, i want place reordered texts of 1 indesign document another. did slow version export , import. think should possible lot faster. my idea store coords , textobjects of text boxes array, sort upon needs , insert after new document. i first step managed insert sorted content new document, without formatting information. possible insert complete text object existing textframe of new document? here's code building object, maybe knows how place object: //loop through every text frame of current page , store properties of each text frame associative array var mypage = mydocumenta.pages.item(0); var mytextframes = mypage.textframes; var mytest = new array(); var mycoords = new array(); for(var mycounter = 0; mycounter < mytextframes.length; mycounter++) { var mycoordstemp = mytextframes.item(mycounter).geometricbounds + " "; mycoords = mycoordstemp.split(","); var mysortcrit = truncate(mycoords[0]) * 10000 + truncate(mycoords[1]); var mytext = mytextframes.item(mycounter).parentstory.texts.item(0); mytest[mycounter] = {mytextframe:mytextframes.item(mycounter), xcoord:mysortcrit, mytextframecontent:mytext} } var mydocumentb = app.documents.add(); var mypageb = mydocumentb.pages.item(0); var mytextframeb = mypageb.textframes.add({geometricbounds:mygetbounds(mydocumentb, mypageb)}); for(var mycounter = 0; mycounter < mytest.length; mycounter++) { alert(mytest[mycounter].mytextframecontent.contents); // missing: insert textframecontent into mytextframeb }
the 'contents' property of text frame contains unicode characters; it's regular javascript string.
to duplicate formatted text, use duplicate function on texts property of original one. cannot move formatted text variable, have copy source destination.
that said: since moving text frames (not "text boxes" ) around, might use duplicate on original frame itself. places copy new document on random position, paste does, need move correct position.
More discussions in InDesign Scripting
adobe
Comments
Post a Comment