Copy link to clipboard
Copied
Thanks in advance for help anyone can give. I'm trying to figure out how to rearrange pages by keywords already in the text. For example: We have a PDF with 100 invoices for band books and want to arrange them by instrument. Using the search function, I can find every place the word "Flute, or Trumpet" appears, but I'm hoping to find a way to search for "Flute" and then move those pages together to the top of the PDF. Repeating this for each instrumentation until all 100 pages are rearranged in the order we need.
The only way I know of to rearrange pages, is by selecting each thumbnail (either in the thumbnail preview bar at the side, or in the "organize pages" function) and manually moving them into place. A few searches I've done lead me to think I need to use some sort of Script? I'm still in the learning phase, and don't understand yet what that means.
You're Awesome!! That's exactly the action I was picturing being able to do!
Hi,
Here is a new file with an action wizard and a field with the script.
Previously I told you somethin wrong ("In this script the word is used as a variable"). This is something I though to do but I didn't. So you can look for "2 Black Titans"... and you can (normally) search from 1 up to several numbers of words.
@+
Copy link to clipboard
Copied
This is not sorting out the pages
Copy link to clipboard
Copied
Before the script:
The script:
And after the script:
@+
Copy link to clipboard
Copied
Copy link to clipboard
Copied
and how you are adding the script in the PDF file? Using JavaScript tool?
Copy link to clipboard
Copied
You can't run this script in document level.
Either you copy/paste the script in the console then select all and press the Enter key (numerical panel) or you install the action wizzard attached in the file I shared.
@+
Copy link to clipboard
Copied
Through which app that wizard will be installed? It says App associated to open this is not available.
Copy link to clipboard
Copied
Or do I need to paste the file in Installation directory? If yes in which location?
Copy link to clipboard
Copied
OK, I have installed the Action Wizard now it is working.
Can I add Keywords,
1. 2 Black Titans
2. 2 Grey Titans
3. 2 Blue Titans
4. 2 White Titans
In this same code? If yes, do I need to add space between words? Thanks for your help. After this I am 100% done. Thanks alot
Copy link to clipboard
Copied
var theWords = ["2 Black Titans","2 Blue Titans","2 Grey Titans","2 White Titans", "Originals","Snap","Extender"];
//
d0 = new Date();
debut = util.printd("dd-mm HH:MM", d0);
for (var i = 0; i <= theWords.length; i++) eval("pages" + i + "=[]");
var nbpages = this.numPages;
var page = 0;
var nbmots = 0;
for (var p = 0; p < nbpages; p++) {
console.clear();
console.show();
console.println("Start of processing:" + debut);
console.println("Process of the page " + (p + 1));
console.println(nbmots + " word(s) found.");
var numWords = this.getPageNumWords(p);
for (var i = 0; i < numWords; i++) {
var found = 0;
var ckWord = this.getPageNthWord(p, i, true);
for (var j = 0; j < theWords.length; j++) {
if (ckWord == theWords[j]) {
eval("pages" + j + ".push(p)");
found++;
nbmots += 1;
break;
}
}
if (found) break;
}
if (!found) eval("pages" + theWords.length + ".push(p)");
}
for (var i = 0; i <= theWords.length; i++) {
for (var j = 0; j < eval("pages" + i + ".length"); j++) {
this.insertPages({
nPage: this.numPages - 1,
cPath: this.path,
nStart: eval("pages" + i + "[j]")
});
}
}
this.deletePages(0, nbpages - 1);
df = new Date();
fin = util.printd("dd-mm HH:MM", df);
console.println("End of processing:" + fin);
delta = (df.valueOf() - d0.valueOf()) / 1000 / 60;
console.println("Time of processing:" + delta + " minutes");
switch (nbmots) {
case 0:
app.alert("No word has been found, so no page has been moved", 3);
break;
case 1:
app.alert("Only one word has been found, so you will now find it in page 1.", 3);
break;
default:
app.alert(nbmots + " words have been found, so you will now find them on the " + nbmots + " first pages.", 3);
}
Copy link to clipboard
Copied
I used this code, but it is not working
Copy link to clipboard
Copied
It's not possible with this script which only search one word. If you are searching a suit of words, it must be improve...
In this script the word is used as a variable, so we can merge the words to create a variable, but a variable can't start with a digit!
So, in your case, can we onlysearch for "Black Titans" or "Grey Titans"... That would make the script easier!
@+
Copy link to clipboard
Copied
How we can do that Black Titans?
Copy link to clipboard
Copied
I have to modify the script.
I'll do that in the day.
@+
Copy link to clipboard
Copied
Thanks a lot for helping. I will be waiting for modified script.
Copy link to clipboard
Copied
Hi,
Here is a new file with an action wizard and a field with the script.
Previously I told you somethin wrong ("In this script the word is used as a variable"). This is something I though to do but I didn't. So you can look for "2 Black Titans"... and you can (normally) search from 1 up to several numbers of words.
@+
Copy link to clipboard
Copied
Thank you so much brother This is working now.
I am wondering if there is a way we can use " 2 Titans / 2 Blak Titans" as a keyword in this script?
I tried it but there is forward slash that is causing problem. Thanks!
Copy link to clipboard
Copied
Hi,
You can search "2 Titans 2 Black Titans" forgetting the slash, that should work, else it's still an other adaptation but I'll not be able to do it today...
@+
Copy link to clipboard
Copied
I have tried this way, but it is not reading it. Also have tried under quotations and eliminating with backslash, but not executing this.
Ok, I will wait for tomorrow. Thanks!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi, Thanks for this. But it is showing this error.
Copy link to clipboard
Copied
It shows this error if I sort out only these Keywords that you mentioned in his code
Copy link to clipboard
Copied
It is working now. Thanks!
Copy link to clipboard
Copied
...and do you know why did you get the error?
@+
Copy link to clipboard
Copied
Same error again
Copy link to clipboard
Copied
Have a look at your PM, I sent you a message for sharing your file.
@+