πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
7 messages
7 total messages Started by Matt_Hollowell Sat, 13 Dec 2008 18:43
[CS3 JS] Move pages from one document to another?
#2502
Author: Matt_Hollowell
Date: Sat, 13 Dec 2008 18:43
18 lines
2253 bytes
First, a brief explanation of what I am trying to do. I have several individual chapters that I am including in an INDD book. However, I also want to be able to allow those individual chapters to stand alone, meaning that I want to add a cover/title page to each chapter file (these two pages would be placed before the current page 1 of each chapter).

My preference would be to write a script that would open the cover/tp file and open the first chapter file; this part is no problem. Where I am running into trouble however, is the second step: moving the cover/tp pages (2 pages) over into the chapter file.

Manually, I would open Cover.indd, activate the "move pages" menu, "Move pages: 1-2", "Destination: Before_Page 1", "Move to: Chapter1.indd".

With over 100 chapters in the book, however, I would prefer to automate the process. I have looked into the Page.move and PageItem.move elements, but both look like they would require a location in the current document (either in (x,y) form or using "AT_BEGINNING".

If I cannot get this to work, I will likely try to insert two blank pages, then cut/paste with a script, but I would prefer the "move" functionality, if it is possible.

A couple of answers to potential questions:
I can't simply place the INDD cover file b/c it uses a text variable to pull the chapter name; this personalizes each stand-alone chapter.
Same answer to why I can't just slap the 2-page .pdf on the front of each. I need the text variable to still be active.

Has anyone tried to move pages from one document to another using scripting? I tried to explain what I am trying to do, but if it doesn't make sense, I can try again. :)

thanks!
Matt
Re: [CS3 JS] Move pages from one document to another?
#2513
Author: loic_aigon
Date: Sat, 13 Dec 2008 23:13
2 lines
853 bytes
Why not removing the text variable from the cover itself and place it at the end with the script ? Hence, you can place the cover files (as pdf or indd) rather than copy/pasting. In any case, you will have to add pages on top of your chapter.
Loic
Re: [CS3 JS] Move pages from one document to another?
#2522
Author: Matt_Hollowell
Date: Sun, 14 Dec 2008 15:46
5 lines
1066 bytes
I'm afraid that placing the text variable on the page, in the correct position, might be beyond my scripting knowledge. I think that using scripting to move pages from one document to another would be a useful avenue to explore; if that does not pan out, I will probably insert two blank pages, then copy/paste.

I like scripting the text variable option, too. Perhaps I will play with that for a while and see what I can discover.

Thanks for replying Loic.
Re: [CS3 JS] Move pages from one document to another?
#2529
Author: loic_aigon
Date: Sun, 14 Dec 2008 22:43
3 lines
852 bytes
copy/paste is easy but...You may have page items on a locked layer, master spreads applied, items overriden,etc. At the end a lot things to deal with.
I can't imagine placing a text variable is that complex. I will have a look and tell you.
Loic
Re: [CS3 JS] Move pages from one document to another?
#2530
Author: 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
Re: [CS3 JS] Move pages from one document to another?
#2534
Author: Matt_Hollowell
Date: Mon, 15 Dec 2008 04:35
4 lines
872 bytes
Thanks so much for taking the time to work this through, Loic! I really appreciate it. I will give the script a test drive tomorrow.

Thanks,
Matt
Re: [CS3 JS] Move pages from one document to another?
#2334
Author: BalοΏ½zs_Slemmer
Date: Sat, 27 Dec 2008 18:35
21 lines
1609 bytes
I know it's quite an old topic, but I'd like share, that you actually can move pages using scripting, and of course using the Page.move() function.

its syntax goes like this:
Page.move(to, reference, binding)

where 'to' stands for a LocationOption, to specify where you want to place the page relative to the reference object.
'reference' is the key part, because it can also be a page in any open document, you just need to refer to it.
'binding' defines the location of the binding spine.

And an example, to see this in action:
// Script from here
var coverDoc = app.documents.item('cover_document');
var pagesToMove = coverDoc.pages.itemByRange(0, 1);
var chapterDoc = app.documents.item('chapter_document');
pagesToMove.move(LocationOptions.BEFORE, chapterDoc.pages.item(0));
// Script until here

You may also use duplicate() the same way, if you want to keep the original pages. (however, it doesn't have the 'binding' parameter)

I hope it can help you!
Bali
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads