These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Batch Sequence modifing as a folderscript possible

Gebhard
Registered: Jul 18 2011
Posts: 25
Answered

Hello Forum,
I know there is many Software for splitting one big PDF into more single Pdfs, but I wan´t to do with this a folderscript.
After reading and reading and reading the Documentation from Adobe Java and API I get this script running as a Batch sequence, but I´m not able to make a folderscript with my menuItm tools that makes the same.
Here is the code from my Batchsequence running well:
/* EinzelSeitenEntnehmen */
var re = /\.pdf$/i;
var filename = this.documentFileName.replace(re,"");
try
{
for ( var i = 0; i < this.numPages; i++ )
this.extractPages
({
nStart: i,
cPath: "/c/temp/"+filename+"_00" + (i +1)+".pdf"
});
}
catch (e)
{
console.println("Batch Aborted: " + e )
}
And Here is my folderScript:
/*Extract Pages to Folder*/
// regular expression acquire the base name of file
extractPages = app.trustedFunction(function()
{
var re = /\.pdf$/i;
var filename = this.extractPages.replace(re,"");
try
{
for ( var i = 0; i < this.numPages; i++ )
this.extractPages
({
nStart: i,
cPath: "/c/temp/"+filename+"_" + (i +1)+".pdf"
});
}
catch (e)
{
console.println("Batch Aborted: " + e )
}
}
)
  
// add the menu item
app.addMenuItem({
cName: "splitpages1JS", // this is the internal name used for this menu item
cUser: "Einzelseiten Trennen", // this is the label that is used to display the menu item
cParent: "Tools", // this is the parent menu. The file menu would use "File"
cExec: "extractPages()",// this is the JavaScript code to execute when this menu item is selected
cEnable: "event.rc = (event.target != null);", // when should this menu item be active?
nPos: 1
});
Acrobat is loading the script with no error in the debugger and I can execute it, but there are no Results in the cPath folder
Please help me again
kind Regards
Gebhard

My Product Information:
Acrobat Pro 8.2.6, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
extractPages() is the name of a method of the Document object, so it's possible your function conflicts with it.
Try renaming it to something else, like myExtractPages().

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Gebhard
Registered: Jul 18 2011
Posts: 25
Hello try67,
it was not "Try renaming it to something else, like myExtractPages().
I modifyed the Script in this way and its now running:
/*Extract Pages to Folder*/
// regular expression acquire the base name of file
ProcessDocument3 = app.trustedFunction(function()
{
for ( var i = 0; i < this.numPages; i++ )
this.extractPages ({
nStart: i,
cPath: "/c/temp/"+this.documentFileName+"_" + (i +1)+".pdf"
});
}
)

// add the menu item
app.addMenuItem({
cName: "splitpages1JS", // this is the internal name used for this menu item
cUser: "Einzelseiten Trennen", // this is the label that is used to display the menu item
cParent: "Tools",// this is the parent menu. The file menu would use "File"
cExec: "ProcessDocument3()",// this is the JavaScript code to execute when this menu item is selected
cEnable: "event.rc = (event.target != null);", // when should this menu item be active?
nPos: 1
});
I think the Problem was filename I changed it in this.documentFileName
and
extractPages = app.trustedFunction(function( in ProcessDocument3 = app.trustedFunction(function(

So now its running perfectly all Scripts together.
I try to send my last Problem today or tommorow
Thank you very very much
kind regards
Gebhard