Highlighted

Script for skipping to next page (of imported pdf/ai/ind)?

Advocate ,
Aug 08, 2020

Copy link to clipboard

Copied

Hey Community and scripting gurus,

 

i've done this in applescript for pdf, but im on a pc now and still struggeling with java. Tho I guess someone done this before, it seems so obvious to have:

Im looking for a script to skip to next page, of a placed multipage-document. 

 

As im thinking about it: at a basic level, what also can work would be a script to reload the linked document, with import-options shown.

 

But then I need to know exactly which page was imported, and with that small preview-section-window it can be quite difficult to find, if you only go by visual. Also i discovered - while having these lack of any programming skills - that there is (maybe) no way to tell the max-count of pages of placed documents within the InD-DOM, to not skip into an non-existing pages at the eof and I ended up calling Acrobat for that (which is mostly running anyway), than skip to the first page again.

 

I dream of a script which can skip to next page for placed PDFs, AIs and InDesign-docs. If the last page is shown, it should skip to first page. In the top of the scripts code can be a variable to reverse the order to backwards skipping, so I can save a second version and keybind both scripts, if I want to use the previous page. Also nice if you have skip too far ahead and the doc is large. 

 

Anyone got this laying around or is saying "pfff EZ - giv me 4 mins" it would be very appriciated!

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi Jan,

years ago John Hawkinson did a script that would invoke the place options on an already placed PDF, InDesign page or AI file, I think. Hope, I can find the old thread or the ExtendScript code. You could build on this. But be warned: Not all PDFs would show how many pages are inside. At least you cannot see this by scripting.

 

Ah. Found the extended script I did, based on John's original one:

 

 

// PlaceAgain-PlaceOptionsShowing-SELECTION.jsx
// Uwe Laubender

//DESCRIPTION:Select a placed image, PDF or InDesign document to replace it with itself getting options

/**
* @@@BUILDINFO@@@ PlaceAgain-PlaceOptionsShowing-SELECTION.jsx !Version! Fri Sep 09 2016 14:09:53 GMT+0200
*/

/*
	Posted in this thread at Adobe InDesign Forum:
	"Toggle pages of a linked Indesign document inside Indesign?"
	mmackinven | Sep 9, 2016
	https://forums.adobe.com/message/8993859#8993859
	
	You can either select the placed file directly or its container frame.
	Or, if its part of a group, the group itself.
	Or, if the container frame is pasted inside another object, that object.
	
*/

placeAgainSelection();

function placeAgainSelection()
{
	if(app.documents.length == 0){alert("ERROR"+"\r"+"No document is open."); return};
	if(app.selection.length != 1){alert("ERROR"+"\r"+"Select one single item containing a placed file."); return};

	// The placed object is selected:
	if
	(
		app.selection[0].constructor.name == "ImportedPage" || 
		app.selection[0].constructor.name == "PDF" ||
		app.selection[0].constructor.name == "EPS" ||
		app.selection[0].constructor.name == "Image" ||
		app.selection[0].constructor.name == "PICT" ||
		app.selection[0].constructor.name == "WMF"
	)
	{	
		var graphic = app.selection[0];
	};
	
	else if(app.selection[0].allGraphics.length == 0){return};
	
	// The container of the placed object is selected:
	else{var graphic = app.selection[0].allGraphics[0]};

	// Two important checks:
	// Case 1: Graphic was pasted on the page from e.g. PhotoShop:
	if(graphic.itemLink == null){alert("ERROR"+"\r"+"The graphic was pasted on the page. The original file cannot be found.");return};
	// Case 2: Link is not available, because placed graphic was renamed, removed or otherwise is not available:
	var file = File(graphic.itemLink.filePath);
	if(!file.exists){alert("ERROR"+"\r"+"\""+file.name+"\""+"\r"+"File cannot be found."); return};
	
	// If you cancel the place options dialog, no error will be thrown:
	try{
	graphic.place(file,true);
	}catch(e){};
};

 

 

Important Note:

The original thread from 2016 where I posted the script code did not make it to the new InDesign forum.

 

Because of that this thread where I mentioned my script is rendered useless:

https://community.adobe.com/t5/indesign/swapping-pages-of-a-linked-file-indesign-file-without-replacing-the-file-and-choosing-the-page/m-p/10403771?page=1

 

This one as well, but there is also a link to a script by Roland Dreger that could be useful:

https://community.adobe.com/t5/indesign/linked-ai-file-change-artboard/m-p/10444575?page=1

 

Regards,
Uwe Laubender

( ACP )

Topics

Feature request, Scripting

Views

99

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

Script for skipping to next page (of imported pdf/ai/ind)?

Advocate ,
Aug 08, 2020

Copy link to clipboard

Copied

Hey Community and scripting gurus,

 

i've done this in applescript for pdf, but im on a pc now and still struggeling with java. Tho I guess someone done this before, it seems so obvious to have:

Im looking for a script to skip to next page, of a placed multipage-document. 

 

As im thinking about it: at a basic level, what also can work would be a script to reload the linked document, with import-options shown.

 

But then I need to know exactly which page was imported, and with that small preview-section-window it can be quite difficult to find, if you only go by visual. Also i discovered - while having these lack of any programming skills - that there is (maybe) no way to tell the max-count of pages of placed documents within the InD-DOM, to not skip into an non-existing pages at the eof and I ended up calling Acrobat for that (which is mostly running anyway), than skip to the first page again.

 

I dream of a script which can skip to next page for placed PDFs, AIs and InDesign-docs. If the last page is shown, it should skip to first page. In the top of the scripts code can be a variable to reverse the order to backwards skipping, so I can save a second version and keybind both scripts, if I want to use the previous page. Also nice if you have skip too far ahead and the doc is large. 

 

Anyone got this laying around or is saying "pfff EZ - giv me 4 mins" it would be very appriciated!

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi Jan,

years ago John Hawkinson did a script that would invoke the place options on an already placed PDF, InDesign page or AI file, I think. Hope, I can find the old thread or the ExtendScript code. You could build on this. But be warned: Not all PDFs would show how many pages are inside. At least you cannot see this by scripting.

 

Ah. Found the extended script I did, based on John's original one:

 

 

// PlaceAgain-PlaceOptionsShowing-SELECTION.jsx
// Uwe Laubender

//DESCRIPTION:Select a placed image, PDF or InDesign document to replace it with itself getting options

/**
* @@@BUILDINFO@@@ PlaceAgain-PlaceOptionsShowing-SELECTION.jsx !Version! Fri Sep 09 2016 14:09:53 GMT+0200
*/

/*
	Posted in this thread at Adobe InDesign Forum:
	"Toggle pages of a linked Indesign document inside Indesign?"
	mmackinven | Sep 9, 2016
	https://forums.adobe.com/message/8993859#8993859
	
	You can either select the placed file directly or its container frame.
	Or, if its part of a group, the group itself.
	Or, if the container frame is pasted inside another object, that object.
	
*/

placeAgainSelection();

function placeAgainSelection()
{
	if(app.documents.length == 0){alert("ERROR"+"\r"+"No document is open."); return};
	if(app.selection.length != 1){alert("ERROR"+"\r"+"Select one single item containing a placed file."); return};

	// The placed object is selected:
	if
	(
		app.selection[0].constructor.name == "ImportedPage" || 
		app.selection[0].constructor.name == "PDF" ||
		app.selection[0].constructor.name == "EPS" ||
		app.selection[0].constructor.name == "Image" ||
		app.selection[0].constructor.name == "PICT" ||
		app.selection[0].constructor.name == "WMF"
	)
	{	
		var graphic = app.selection[0];
	};
	
	else if(app.selection[0].allGraphics.length == 0){return};
	
	// The container of the placed object is selected:
	else{var graphic = app.selection[0].allGraphics[0]};

	// Two important checks:
	// Case 1: Graphic was pasted on the page from e.g. PhotoShop:
	if(graphic.itemLink == null){alert("ERROR"+"\r"+"The graphic was pasted on the page. The original file cannot be found.");return};
	// Case 2: Link is not available, because placed graphic was renamed, removed or otherwise is not available:
	var file = File(graphic.itemLink.filePath);
	if(!file.exists){alert("ERROR"+"\r"+"\""+file.name+"\""+"\r"+"File cannot be found."); return};
	
	// If you cancel the place options dialog, no error will be thrown:
	try{
	graphic.place(file,true);
	}catch(e){};
};

 

 

Important Note:

The original thread from 2016 where I posted the script code did not make it to the new InDesign forum.

 

Because of that this thread where I mentioned my script is rendered useless:

https://community.adobe.com/t5/indesign/swapping-pages-of-a-linked-file-indesign-file-without-replacing-the-file-and-choosing-the-page/m-p/10403771?page=1

 

This one as well, but there is also a link to a script by Roland Dreger that could be useful:

https://community.adobe.com/t5/indesign/linked-ai-file-change-artboard/m-p/10444575?page=1

 

Regards,
Uwe Laubender

( ACP )

Topics

Feature request, Scripting

Views

100

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 ,
Aug 08, 2020

Copy link to clipboard

Copied

It may be that I have not had enough coffee yet, but I don't know exactly what you want. You want to skip to the next page within the InDesign document to the page containing the next page of the placed document?

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 ,
Aug 08, 2020

Copy link to clipboard

Copied

You can put Previous / Next Page arrows on the Master Page and say a "button" stating, for example, "Cover" which will appear say at the bottom of each page.

That's easy and you can remove them, as appropriate from the Cover, so it's just Next.

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...
Advocate ,
Aug 08, 2020

Copy link to clipboard

Copied

Guys, no no no 🙂 ill try to clear this up:

I have placed a multi-page PDF in my InDesign document, showing page 3 of 10, which I have choosen within the import-options dialog.

But now I want to show page 4. While InDesign tries to help me browsing where I last browsed for assets, this feature doesnt come in handy when you are trying to relocate the pdf-file, just for re-importing to get the import dialog.

if im not wrong, there is now slick way to change the choice of imported page.

I know, I can switch off the browsing behavoir in preferences, but that comes in more handy than it bothers me.

 

id prefer InDesign to have the ability to throw an import-options dialog while drag and dropping from the explorer, but it doesnt. All I know is holding shift while choosing "place" to get the importoptions, not having ticker that checkbox (thanks to InDesignSecrets).

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 ,
Aug 08, 2020

Copy link to clipboard

Copied

Can you post the AppleScript that you have been using? Then we don't have to start from scratch, translating it into Javascript (not 'Java'! That's an entirely different language!).

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...
Advocate ,
Aug 10, 2020

Copy link to clipboard

Copied

Sorry for the late reply. 

Its like that: ive lost my job due outsourcing to vietnam, throwing me back to me windows-pc at home, and I cant look into these files. Its a 2015-ish version, but it must have worked. Here it is, 7 days: 

https://we.tl/t-cNQpMxz6HX 

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 ,
Aug 10, 2020

Copy link to clipboard

Copied

Your zip archive is empty

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...
Advocate ,
Aug 11, 2020

Copy link to clipboard

Copied

Lets try again. This time i directly dnd both of the .scpt-files into wetransfer, this should work. 

https://we.tl/t-iaphO1PPme

I took some files from mac to my home PC, and I can open my .applescript files. But windows is struggeling getting some content out of these .scpt ones, tho - if I remember correct - the same app AppleScriptEditor does compute both filetypes on MacOS. Why there are .scpt and .applescript I never thought about that till now.

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...
Advocate ,
Aug 11, 2020

Copy link to clipboard

Copied

Meh, i found this: https://stackoverflow.com/questions/47238566/applescript-syntax-all-messed-up-how-to-re-build

My code looks exactly like what happened there. I dont think i can retrieve it without my old mac.

 

But actually I dont think the script wont be much of a help, since my "style" is unlearned and sloppy I guess.

But all the script did - and I guess you guys have code snippets for this already in place in more efficient quality - was inspect the selected container for a link. If not pdf, then just beep, else get the filepath, place/reload document from filepath with importoptions, increasing the pageNumer, which I can read from my link.

 

Only hurdle is, but probably solved with a good error handler, to not skip to next page if the last page is choosen. I ended up calling Acrobat, because I found in Acrobat DOM a maxPage or something.
But I can imagine, because in "InDesign" i dont know the maxpage of the imported PDF, to just try to import next page, and if an error is caught while importing, just start with page 1 again.

 

 https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PDFAttribute.html#d1e207760

>> import

pageNumber

 

 

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 ,
Aug 11, 2020

Copy link to clipboard

Copied

Hi Jan,

do I understand this right?

 

You placed multipage PDFs.

And you want to write a script that will place the next page of a given placed PDF page?

If there is no next page you start over with the first page.

 

Regards,
Uwe Laubender

( ACP )

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...
Advocate ,
Aug 12, 2020

Copy link to clipboard

Copied

Hello Uwe,

thats right, exactly.

I would add "into the selected container", to not have the next page hanging in my place gun.

 

A v2 of the script could deal with .ai and .indd too, but they use a different set of import options, which also means more stuff to secure. 

 

It could also be a InD feature in the linklist, like little arrows appearing when hovering over a supporting linklist item, or at the default-shown blue "link mark" on a image container.

 

Uwe, the story is: Since Im on PC now, im struggeling starting with js again. Im deep into making a (paper) personal design folder for upcoming job interviews. And my home PC is really lacking the UX adjustments Ive done to my work mac 😞 And I have placed like a thousand pdfs from 13 years of work to narrow down, and most hold more than one page. When I want to show page 2 I have to re-browse to the file, which is the really annoyance here. The OSX finder was good at finding, but the windows explorer isnt. 

 

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...
Advocate ,
Aug 12, 2020

Copy link to clipboard

Copied

...as im think further about the feature: InDesign should really have a "show importoptions again"-feature, a bit like the "object layer options" feature. This would be an easy script, but I think that feature should belong into the default toolbox of InDesign.

When I have more time on my hands, I will make a feature request for that. 

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 ,
Aug 12, 2020

Copy link to clipboard

Copied

Hi Jan,

years ago John Hawkinson did a script that would invoke the place options on an already placed PDF, InDesign page or AI file, I think. Hope, I can find the old thread or the ExtendScript code. You could build on this. But be warned: Not all PDFs would show how many pages are inside. At least you cannot see this by scripting.

 

Ah. Found the extended script I did, based on John's original one:

 

 

// PlaceAgain-PlaceOptionsShowing-SELECTION.jsx
// Uwe Laubender

//DESCRIPTION:Select a placed image, PDF or InDesign document to replace it with itself getting options

/**
* @@@BUILDINFO@@@ PlaceAgain-PlaceOptionsShowing-SELECTION.jsx !Version! Fri Sep 09 2016 14:09:53 GMT+0200
*/

/*
	Posted in this thread at Adobe InDesign Forum:
	"Toggle pages of a linked Indesign document inside Indesign?"
	mmackinven | Sep 9, 2016
	https://forums.adobe.com/message/8993859#8993859
	
	You can either select the placed file directly or its container frame.
	Or, if its part of a group, the group itself.
	Or, if the container frame is pasted inside another object, that object.
	
*/

placeAgainSelection();

function placeAgainSelection()
{
	if(app.documents.length == 0){alert("ERROR"+"\r"+"No document is open."); return};
	if(app.selection.length != 1){alert("ERROR"+"\r"+"Select one single item containing a placed file."); return};

	// The placed object is selected:
	if
	(
		app.selection[0].constructor.name == "ImportedPage" || 
		app.selection[0].constructor.name == "PDF" ||
		app.selection[0].constructor.name == "EPS" ||
		app.selection[0].constructor.name == "Image" ||
		app.selection[0].constructor.name == "PICT" ||
		app.selection[0].constructor.name == "WMF"
	)
	{	
		var graphic = app.selection[0];
	};
	
	else if(app.selection[0].allGraphics.length == 0){return};
	
	// The container of the placed object is selected:
	else{var graphic = app.selection[0].allGraphics[0]};

	// Two important checks:
	// Case 1: Graphic was pasted on the page from e.g. PhotoShop:
	if(graphic.itemLink == null){alert("ERROR"+"\r"+"The graphic was pasted on the page. The original file cannot be found.");return};
	// Case 2: Link is not available, because placed graphic was renamed, removed or otherwise is not available:
	var file = File(graphic.itemLink.filePath);
	if(!file.exists){alert("ERROR"+"\r"+"\""+file.name+"\""+"\r"+"File cannot be found."); return};
	
	// If you cancel the place options dialog, no error will be thrown:
	try{
	graphic.place(file,true);
	}catch(e){};
};

 

 

Important Note:

The original thread from 2016 where I posted the script code did not make it to the new InDesign forum.

 

Because of that this thread where I mentioned my script is rendered useless:

https://community.adobe.com/t5/indesign/swapping-pages-of-a-linked-file-indesign-file-without-replac...

 

This one as well, but there is also a link to a script by Roland Dreger that could be useful:

https://community.adobe.com/t5/indesign/linked-ai-file-change-artboard/m-p/10444575?page=1

 

Regards,
Uwe Laubender

( ACP )

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 ,
Aug 12, 2020

Copy link to clipboard

Copied

Also see into the following thread where I tested my code from 2016 on an placed AI file with InDesign 2020:

 

Linked ai files in Indesign
Laubender
Adobe Community Professional , Feb 25, 2020
https://community.adobe.com/t5/indesign/linked-ai-files-in-indesign/m-p/10945947#M176764

 

Regards,
Uwe Laubender

( ACP )

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...