Skip to main content
Jason Burnett
Inspiring
January 14, 2024
Question

Help with simple repagination script

  • January 14, 2024
  • 2 replies
  • 1412 views

I have a 100 page cookbook that I need to print 2 up side by side on an 8.5x11 in page. Since this is not a booklet, using the Print As Booklet option won't work.

 

I created the output in InDesign and printed the pagesto a PDF.

I would like to now reorder the pages using this method:

4,1  2,3  8,5 6,7  etc.

This will allow me to print 2 up double sided and original page 1 will be married up with original page 2 and so on for the entire document.

A javascript loop might look something like:

let pages=document.pages;

let pagecount=pages.length;

for (var p=3;p<pagecount;p+=4) {

let fourthPage=pages.splice(p,1);

pages.splice(p-3,0,fourthPage);

}

Basicallly it would extract every fourth page and insert it at the front of those 4 pages resulting in a new page order.

 

Please tell me someone can help with this. It seems like such a simple request. Any help would be appreciated. 

 

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
January 14, 2024

This code should do the trick:

 

for (var p=3; p<this.numPages; p+=4) {
	this.movePage(p, p-4);
}
Jason Burnett
Inspiring
January 14, 2024

Thanks a ton. This is great but what on Earth is going on with the javascript portion of Acrobat?

I select Use JavaScript and a panel opens with 4 options:

Debugger

Document Javascript Strings

All Javascript Strings

Document Actions

 

I figured since I only want to run this script one time, I'd run it from the console in the Debugger. NOPE.

I figured that I would add it to the Document Strings and was able to Add It, but not execute it

I went back to Debugger to see if it would show up under available scripts...no luck, still can't execute it.

So I look at All Javascript Strings and I can see my previous function was added, still no way to execute it.

So I try Document Actions and it is a set of triggers-none of which work for me because presumably, I will print this a few hundred times and only want this run right now. 

 

What am I missing? How do I run my function defined in Document Strings this one time? Thanks for your help.

Jason Burnett
Inspiring
January 14, 2024

I got it to work by invoking the function call after the definition. Is there a way to ensure that it only happens once. There doesn't seem to be any indication about when it will happen after I define the document string. So I quickly deleted the script after it ran successfully. Thanks for any suggestions.

Abambo
Community Expert
Community Expert
January 14, 2024
ABAMBO | Hard- and Software Engineer | Photographer