Copy link to clipboard
Copied
A pdf/ai can have multiple pages, and when placing it, the user specifies the target page (if not specified, it defaults to 1).
So, is there a way to determine the page of a pdf/ai file that has already been placed as a PlacedItem within a document?
I know there is no direct property to express this. In other words, I am looking for either a workaround method like embedding it first and then examining the PageItem structure, or an unexpected method that elegantly solves this problem.
Similar posts
Here you go, select your placed pdf before running
// Elegant solution to get selected linked PDF item's page number
selection[0].relink(selection[0].file);
var currentPage = app.preferences.getIntegerPreference ("plugin/PDFImport/PageNumber");
alert("Current page number: " + currentPage);
Copy link to clipboard
Copied
Hi @sttk3 sadly I don't know of any way to do this, so I will be watching this question.
I can imagine a very hacky approach that might work in most cases. The script would:
1. export the placed image as svg (with a known position and matrix).
2. place each page of the pdf (give it the same position and matrix) and export as svg.
3. compare 1 with 2 until you find a match (I'm hoping there might be a good place to look for a match, rather than byte-by-byte).
I'm sorry for how terrible that is, but it's all I can think of. I will wait to see if anyone has any good ideas.
- Mark
Copy link to clipboard
Copied
Thank you for your idea. At the moment, the only method I can think of is the messy one that we have suggested. I wish there were a simpler way.
Copy link to clipboard
Copied
Here you go, select your placed pdf before running
// Elegant solution to get selected linked PDF item's page number
selection[0].relink(selection[0].file);
var currentPage = app.preferences.getIntegerPreference ("plugin/PDFImport/PageNumber");
alert("Current page number: " + currentPage);
Copy link to clipboard
Copied
Carlos you absolute LEGEND!! 😄
Copy link to clipboard
Copied
😁
Copy link to clipboard
Copied
Wonderful! You are now at the forefront of humanity!
Copy link to clipboard
Copied
Wonderful! You are now at the forefront of humanity!
By @sttk3
that's a bit much Lol
but thanks for the nomination 😂
Copy link to clipboard
Copied
By the way, Carlos, I have a script I use a lot—it justs switches pages of placed .ai files. Now with your method to get the page number, I've made that script work better (no need to type in the page I wanted). FYI I've just put the script here.
- Mark
Copy link to clipboard
Copied
wow nice application of the concept!! I like simple, effective scripts
Copy link to clipboard
Copied
There was an object that was more accessible in the script for getting the current page number.
var currentPage = app.preferences.PDFFileOptions.pageToOpen ;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now