Copy link to clipboard
Copied
Hello everyone, I am new to using Acrobat. I have ten (10) pages named page 1 through page 10. I'd like to have page 1 have a drop down box and a button. The drop down box would have number 1-5.
A default selection in drop down box would be 1. The default setup for the PDF would be pages 1-4. I would like it if the user selects number 2 from drop down box, then I would like page 5 added to PDF. If user selects value 2 from drop down box then page 6 would be added to PDF.If user selects value 3 from drop down box, then I would like page 7 added.
To be clear...the default setup would be pages 1-4 visible. Pages 6-10 as non-visible. Then depending on selection an additional page (from page 5 to 10) would be added to PDF.
Also I would like after user picks number 1-5 from drop down box that the user has to press the button to actual have the above action to happen.
And if possible I would like a selection to delete or hide a selection made an error. Like if they wanted to select value number 2 from drop down box but selected number 5 in error.
Could someone walk me through this process?
To do that you would need to define those pages as Templates, hide them, and then spawn pages from them or make them visible again, depending on how the file is going to be used. If it's going to be used in Reader you have to spawn pages; If it will only be used in Acrobat then you can simply make them visible. Either way, it will require using a script.
Copy link to clipboard
Copied
To do that you would need to define those pages as Templates, hide them, and then spawn pages from them or make them visible again, depending on how the file is going to be used. If it's going to be used in Reader you have to spawn pages; If it will only be used in Acrobat then you can simply make them visible. Either way, it will require using a script.
Copy link to clipboard
Copied
I can spawn a page using the below code. What would I need to add?
this.getTemplate("2") .spawn ({nPage: this.numPages, bRename: false, bOverylay: false});
I am using Adobe Acrobat Pro.
Would using a CLEAR button erase the added pages? How do I get the spawn button to select certain pages depending on the drop down box selection?
Copy link to clipboard
Copied
You can use an if-condition, like this:
if (event.value=="2") this.getTemplate("2") .spawn ({nPage: this.numPages, bRename: false, bOverylay: false});
if (event.value=="3") {
this.getTemplate("2") .spawn ({nPage: this.numPages, bRename: false, bOverylay: false});
this.getTemplate("3") .spawn ({nPage: this.numPages, bRename: false, bOverylay: false});
}
etc.
This code should be used as the custom validation script of your drop-down.
And no, the Clear (or resetForm, if done using a script) command does not delete spawned pages.
You will need to use the deletePages command for that. For example:
if (this.numPages>4) this.deletePages(4, this.numPages-1);
Copy link to clipboard
Copied
Thanks for the script. I was sick for a few days and then had some stuff come up. I ended up using a checkbox. This is the script I have:
if(event.target.value == "Off")
this.deletePages(4);
else
{
var a = this.getTemplate("6");
a.spawn(this.numPages, false, false);
}
It seems to work okay so far. I have 6 pages total. And I have 2 pages hidden. I want to figure out how to extract 1 page out of the 6. And email it. I know the action of a button could be email. I can't figure out what the extract example should look like. Here is the code I found through searching here:
/* Extract pages to folder */
// Regular expression used to acquire the base name of file
var re = /\.pdf$/i;
// filename is the base name of the file Acrobat is working on
var filename = this.documentFileName.replace(re,"");
try {for (var i = 0; i < this.numPages; i++)
this.extractPages({
nStart: i,
cPath: "/F/temp/"+filename+"_" + i +".pdf"
});
} catch (e) { console.println("Aborted: " + e) }
I have a hard time figuring out where to substitute. The page is number 3. Can you give me a dumbed down explanation of this code?
Copy link to clipboard
Copied
You can't do it if the file is going to be used in Reader.
Copy link to clipboard
Copied
I am using the script in Acrobat. I can now spawn the pages. Thank you!