Article View: adobe.scripting.indesign
Article #15666Re: Moving formatted text
From: Olav_Kvern
Date: Thu, 20 Nov 2003 06:18
Date: Thu, 20 Nov 2003 06:18
48 lines
2911 bytes
2911 bytes
Dave--
A few quick points:
* While we wanted to include the ability to move text and page items from one document to another, and I actually thought we'd do it this time, we didn't.
* Exporting and importing tagged text is not a bad way to go, provided you're not using a multiple master font. Tagged text does now include all table formatting, and includes tables nested within tables.
* You can also move the pages containing the text, and then move the text. This might not be a bad way to go. Here's an example:
//MoveTextByMovingPages.js
//You can't move text directly from document to document (without relying on
//import/export or copy/paste. But you can move pages from one document to another,
//and you can move text inside a single document. Therefore....
//This first part sets up two silly documents, each with a single page, text frame, and story.
var myString
var myDocumentA = app.documents.add();
myString = "zebra\rmanatee\rdog\rcat\rchimpanzee\rgorilla\rcow\raardvark\rgolem\r"
myMakeDummy(myDocumentA, myString);
var myDocumentB = app.documents.add();
myString = "potato\rtomato\ryam\rlettuce\rpear\rwalnut\rbok choy"
myMakeDummy(myDocumentB, myString);
//Duplicate one of the pages.
var myPageClone = myDocumentB.pages.item(0).duplicate();
//Move the duplicate page to the end of Document A.
myPageClone = myPageClone.move(LocationOptions.after, myDocumentA.pages.item(-1));
//Move the text from the duplicate page into the first story in Document A
myPageClone.textFrames.item(0).parentStory.move(LocationOptions.atEnd, myDocumentA.pages.item(0).textFrames.item(0).parentStory);
//Delete the duplicated/moved page.
myPageClone.remove();
function myMakeDummy(myDocument, myString){
myPage = myDocument.pages.item(0);
myPageHeight = myDocument.documentPreferences.pageHeight;
myPageWidth = myDocument.documentPreferences.pageWidth;
myX1 = myPage.marginPreferences.left;
myY1 = myPage.marginPreferences.top;
myX2 = myPageWidth - myPage.marginPreferences.right;
myY2 = myPageHeight - myPage.marginPreferences.bottom;
myTextFrame = myPage.textFrames.add(undefined, undefined, undefined, {contents:myString, geometricBounds:[myY1, myX1, myY2, myX2]});
}
Thanks,
Ole
Technical Details
Message-ID:
<2cce7d8f.2@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<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-19 22:37:36 PST From: Olav_Kvern@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: Moving formatted text Message-ID: <2cce7d8f.2@webx.la2eafNXanI> Date: Wed, 19 Nov 2003 22:18:59 -0800 References: <2cce7d8f.-1@webx.la2eafNXanI> Lines: 57 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit