🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15601

Re: Moving formatted text

#15601
From: Olav_Kvern
Date: Sat, 22 Nov 2003 00:32
43 lines
2843 bytes
Gang--

Here's an example containing a function that uses tagged text to replicate text from one text object to another in a document.



//DupMoveText.js 
// 
//----------example document setup---------- 
var myDocument = app.documents.add(); 
myDocument.colors.add({name:"Red", colorValue:[0, 100, 100, 0]}); 
myDocument.colors.add({name:"Blue", colorValue:[100, 50, 0, 0]}); 
var myBounds = new Array; 
myBounds[0] = myDocument.pages.item(0).marginPreferences.top; 
myBounds[1] = myDocument.pages.item(0).marginPreferences.left; 
myBounds[2] = myDocument.documentPreferences.pageHeight - myDocument.pages.item(0).marginPreferences.bottom; 
myBounds[3] = myDocument.documentPreferences.pageWidth - myDocument.pages.item(0).marginPreferences.right; 
myString = "abc\t1b\t1c\r\t\t\r\t\t" 
var myTextFrame = myDocument.pages.item(0).textFrames.add(undefined, undefined, undefined, {geometricBounds:myBounds, contents:myString}); 
var myTable = myTextFrame.parentStory.tables.add(); 
var myString = myTable.cells.item(0).contents; 
myTable.cells.item(0).characters.item(0).fillColor = "Red"; 
myTable.cells.item(0).characters.item(1).fillColor = "Blue"; 
//----------end of example document setup---------- 
// 
myDupMoveText(myTable.cells.item(0).texts.item(0), myTable.rows.item(1).cells.item(0).texts.item(0)); 
myDupMoveText(myTable.cells.item(0).texts.item(0), myTable.rows.item(1).cells.item(1).texts.item(0)); 
myDupMoveText(myTable.cells.item(0).texts.item(0), myTable.rows.item(1).cells.item(2).texts.item(0)); 
myDupMoveText(myTable.cells.item(0).texts.item(0), myTable.rows.item(2).cells.item(0).texts.item(0)); 
myDupMoveText(myTable.cells.item(0).texts.item(0), myTable.rows.item(2).cells.item(1).texts.item(0)); 
myDupMoveText(myTable.cells.item(0).texts.item(0), myTable.rows.item(2).cells.item(2).texts.item(0)); 
//This function moves text from one object to another using tagged text. 
function myDupMoveText(mySourceText, myTargetText){ 
	var myTaggedTextFile = "/c/moveText.txt"; 
	mySourceText.exportFile(ExportFormat.taggedText, File(myTaggedTextFile)); 
	myTargetText.place(File(myTaggedTextFile)); 
}

It's pretty darn fast.

Thanks,

Ole
Technical Details
Message-ID: <2cce7d8f.14@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2cce7d8f.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,2aa45b5334d34582
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-11-21 16:37:55 PST
From: Olav_Kvern@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: Moving formatted text
Message-ID: <2cce7d8f.14@webx.la2eafNXanI>
Date: Fri, 21 Nov 2003 16:32:42 -0800
References: <2cce7d8f.-1@webx.la2eafNXanI>
Lines: 52
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit