Highlighted

Javascript Inverted page number

Community Beginner ,
Dec 14, 2019

Copy link to clipboard

Copied

Any idea to write a javascript for InDesign that insert inverted page number on any page based on document

Adobe Community Professional
Correct answer by Sunil_Yadav1 | Adobe Community Professional

Try this code:

 

var c = 0;
while(c < app.activeDocument.pages.length){
    try{
       var sec = app.activeDocument.sections.add(app.activeDocument.pages[c]);
       sec.continueNumbering = false;
       sec.pageNumberStart = app.activeDocument.pages.length-c;
        }
   catch(e){
       var sec = app.activeDocument.pages[c].appliedSection;
       sec.continueNumbering = false;
       sec.pageNumberStart = app.activeDocument.pages.length-c;
       }
    c++;
    }

 

Best

Sunil

Topics

How to, Scripting

Views

957

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Javascript Inverted page number

Community Beginner ,
Dec 14, 2019

Copy link to clipboard

Copied

Any idea to write a javascript for InDesign that insert inverted page number on any page based on document

Adobe Community Professional
Correct answer by Sunil_Yadav1 | Adobe Community Professional

Try this code:

 

var c = 0;
while(c < app.activeDocument.pages.length){
    try{
       var sec = app.activeDocument.sections.add(app.activeDocument.pages[c]);
       sec.continueNumbering = false;
       sec.pageNumberStart = app.activeDocument.pages.length-c;
        }
   catch(e){
       var sec = app.activeDocument.pages[c].appliedSection;
       sec.continueNumbering = false;
       sec.pageNumberStart = app.activeDocument.pages.length-c;
       }
    c++;
    }

 

Best

Sunil

Topics

How to, Scripting

Views

958

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Dec 14, 2019

Copy link to clipboard

Copied

What do you mean by inverted page number. How do you do it manually, is it just about entering the page number in a frame and then flipping the frame?

 

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Dec 14, 2019

Copy link to clipboard

Copied

NO,

The purpose is :the first logic page number of the document become the last number.

Example a 10 pages document :

the first logic page is 10

the last logic page is 1

Olivier

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Dec 15, 2019

Copy link to clipboard

Copied

Set the binding type to Right-to-Left.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Dec 29, 2019

Copy link to clipboard

Copied

Try this code:

 

var c = 0;
while(c < app.activeDocument.pages.length){
    try{
       var sec = app.activeDocument.sections.add(app.activeDocument.pages[c]);
       sec.continueNumbering = false;
       sec.pageNumberStart = app.activeDocument.pages.length-c;
        }
   catch(e){
       var sec = app.activeDocument.pages[c].appliedSection;
       sec.continueNumbering = false;
       sec.pageNumberStart = app.activeDocument.pages.length-c;
       }
    c++;
    }

 

Best

Sunil

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Dec 14, 2019

Copy link to clipboard

Copied

You could reverse the page order via scripting, but if the page numbers are a special character like Current Page Number the page numbers would get updated and changed as you move the pages. Your page numbers would have to be regular numbers.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Dec 14, 2019

Copy link to clipboard

Copied

The actual page number is accessible via "page.name". I haven't drunk sufficient coffee to figure out an invert mechanism, but parse the name as an int then doing some kind of calc on the total # of pages would probably work. You would take the new figure and reinsert into page.name.

var pages = app.activeDocument.pages;
for (var i = 0; i < pages.length; i++) {
$.writeln(pages[i].name);
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Dec 14, 2019

Copy link to clipboard

Copied

The actual page number is accessible via "page.name".

 

The page name string could be a letter—if the page was a section start using roman numerals, page one of the section would be named "i". There's also page.documentOffset which reurns the page’s sequential number relative to the document.

 

If an auto Current Page Number is being used it might be possible to set every page to a section start and reverse the order of the auto page numbering. I can’t do it easily in JS, but this AppleScript (OSX only) seems to work.

 

 

 

 

tell application "Adobe InDesign CC 2018"
	tell active document
		set allow page shuffle of document preferences to false
		my clearSections()
		set p to every page
		set c to count of p
		repeat with i from 1 to c
			set pn to c - (i - 1)
			set itm to item i of p
			try
				make new section with properties {continue numbering:false, page start:itm, page number start:pn}
			end try
		end repeat
	end tell
end tell

--reset the sections
on clearSections()
	tell application "Adobe InDesign CC 2018"
		tell active document
			set s to every section
			repeat with i from 2 to count of s
				try
					delete item i of s
				end try
			end repeat
		end tell
	end tell
end clearSections

 

 

 

 

Screen Shot 6.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Dec 14, 2019

Copy link to clipboard

Copied

Wonderful.

The result is exacly what I was waiting for.

If the document get new pages, re-run the script.

Thank you. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Dec 14, 2019

Copy link to clipboard

Copied

مجموعة الأدوات منصة        [10] شليلة 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Engaged ,
Jun 11, 2020

Copy link to clipboard

Copied

Wow, Great Job Sunail, Can i ask what if i want to Invert Pages as Well with the Inverted Numbers so Everyting will be Logic? Can this be done ?

Best Regards

Mohammad Hasanin

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Jun 13, 2020

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
medos20 LATEST
Engaged ,
Jun 14, 2020

Copy link to clipboard

Copied

yes, thank you very much

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...