Are you tired of relinking PDF files just to change a page number, only to need to find the folder the file originally at again? Afterward, you forget to click the “Show Import Options”, so you have to do the whole process again? Ah, the joys of Adobe’s usability and user experience…
Don’t fret though! With this script, all you need to do is select the graphic, double-click the script, and enter a page number, It will magically change to the page number you want!
Setup
- In InDesign, open the Scripts panel in
Window > Utilities > Scripts
(or Ctrl+Alt+F11) - Right-click the
User
folder, and selectReveal in Explorer
. - Create a new file called
ChangePDFPage.jsx
with the following code:
"use strict";
function main() {
const selection = app.selection[0];
if (!selection)
return;
if (!(selection instanceof Rectangle))
return;
const graphic = selection.graphics[0];
if (!graphic)
return;
if (!(graphic instanceof Graphic))
return;
const filePath = graphic.itemLink.filePath;
const link = graphic.itemLink;
const pdf = link.parent;
const pageNumber = pdf.pdfAttributes.pageNumber;
const chosenPage = parseInt(prompt("Choose Page Number:", pageNumber.toString()));
if (isNaN(chosenPage)) {
alert("Invalid page number");
return
}
app.pdfPlacePreferences.pageNumber = chosenPage;
graphic.place(filePath, false);
}
function propertiesToString(properties) {
var s = "";
for (var i in properties) {
s += i + " " + properties[i] + "\n";
}
return s;
}
main();
Usage
- Select a linked PDF on the page.
- Double-click on the
ChangePDFPage.jsx
in the Scripts panel. - Input a page number, and press Enter.
- Profit!
Final Remarks
This script can probably be slightly adjusted to work in Adobe Illustrator. If anybody is interested, drop a comment and I can publish the code for that as well.