🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #2530

Re: [CS3 JS] Move pages from one document to another?

#2530
From: loic_aigon
Date: Sun, 14 Dec 2008 23:42
48 lines
2492 bytes
ok here we are
I get a raw skeleton that you will have to adjust but it's functional.
Use a PDF for placement as you can specify the page that you want to place.
I don't know if you can do the same for indesign files.

So basically, it starts adding 2 pages and placeing the pdf in the same time.
After that, it creates the textVariable and the frame that will receive it.

Here you are:

//If a document is open
if(app.documents.length!=0)
{
	var ad = app.activeDocument;

	//Pages placement

	for(i=0; i<2; i++) 	{ 		//Add 2 pages on top of the document; 		var tmpPg = ad.pages.add(LocationOptions.BEFORE, ad.pages[0]); 		//Here you place your pdf 		app.pdfPlacePreferences.pageNumber = i; 		tmpPg.place(File(cover.pdf), false) 		//You should specify page x and page y but ain't found yet the way to go. 	}

	//Text variable creation
	//Check if the textVariable named "txtVar" does not already exist...
	if(ad.textVariables.item("txtVar")==null)
	{
		//if not found, create the text variable named "txtVar"
		var txtVar = ad.textVariables.add();
		txtVar.variableType =VariableTypes.CUSTOM_TEXT_TYPE;
		txtVar.name = "txtVar";
		//Set the contents of the text variables to the string "test"
		ad.textVariables.item("txtVar").variableOptions.contents = "test";
	}

	//these coordinates don't care aboutyour units but you may adjust them to your needs
	var y1 = ad.marginPreferences.left;
	var x1 = ad.marginPreferences.top;
	var y2 = y1+5;
	var x2 = x1+25;
	var myFrame = ad.pages[0].textFrames.add({geometricBounds:[y1,x1,y2,x2]});

	//Set the contents of the frame to the text variables "txtVar"
	myFrame.contents=ad.textVariables.item("txtVar").variableOptions.contents;

	//You may want to stylize the txtVar
	//In this case, either you use a existing characterStyle or you create one in the script
}



Bye Loic
Technical Details
Message-ID: <59b742c7.3@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!news2!newshub.sdsu.edu!webcrossing
References: <59b742c7.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,497db990f6de49b1
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: loic_aigon <loic_aigon@yahoo.fr>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!news2!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: [CS3 JS]  Move pages from one document to another?
Message-ID: <59b742c7.3@webcrossing.la2eafNXanI>
Date: Sun, 14 Dec 2008 15:42:26 -0800
References: <59b742c7.-1@webcrossing.la2eafNXanI>
Lines: 63
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit