Copy link to clipboard
Copied
Hi
I'm trying to extract single and multiple pages based on pre-defined page label names. Probably as an action.
I understand the basics of extracting pages and page labels but can't tie it all together. Any pointers?
Thanks
Copy link to clipboard
Copied
You need to better explain the situation. What are the labels in your file and how do they relate to the way you want to extract the pages?
Copy link to clipboard
Copied
The labels are various page labels. Some are numbers, some are letters and numbers eg. A200.
I want to extract specific pages from a list of page labels and save them as new files.
Hope that makes sense.
Copy link to clipboard
Copied
Where is this list coming from?
Copy link to clipboard
Copied
I have a list of page labels. They could be put into the code by hand.
Copy link to clipboard
Copied
So you have a list of page labels and you want to find the matching pages and extract them as new files, saving them using the label names?
Copy link to clipboard
Copied
Yes correct
Copy link to clipboard
Copied
You can use something like this:
var names = ["Page 1", "Page 2", "Cover page"];
for (var p=0; p<this.numPages; p++) {
var pageLabel = this.getPageLabel(p);
if (names.indexOf(pageLabel)!=-1) {
this.extractPages(p, p, pageLabel + ".pdf");
}
}
Copy link to clipboard
Copied
That's great thanks so much.
Would it be possible to do it for a range of pages as well? Eg "Page1 - Page 6". Where those pages run concurrently, so from "Page 1" to "Page 6".
Copy link to clipboard
Copied
Yes, but it will require a more complex script, especially if you want to compare each one of them to the list.
Copy link to clipboard
Copied
I'll see if I can work out how to put it together.
Thanks so much for your help though. Appreciated.