Copy link to clipboard
Copied
extract 2 pages in pdf for 2 separate files
Save with suffix (the 1: _fill, the 2: _cut)
and add this command in menu
can someone help me?
Thanks!!!
Hello aviel222,
That's what the code is doing, I added comments to the code so you can see what it's doing.
I'm not sure why you would save the pdf with the .ai.pdf extention but the code now addresses that.
//Save this in the ....\Acrobat\Javascripts\ program or user directory
// as a .js file to load as Add-In
app.addSubMenu({ cName: "Custom Tools", cParent: "Edit", nPos: 0 });
app.addMenuItem({ cName: "Extract Page 2 with suffix", cParent: "Custom Tools", cExec: "extractPagesWithSuffix
...
Copy link to clipboard
Copied
Hello aviel222,
Give this a try......
Save the below code in the Acrobat\Javascripts\ program or user directory as a .js file, quite and restart Acrobat.
Under the Edit menu you'll now find Custom Tools > "Extract Pages 1-2 with suffix",
//Save this in the ....\Acrobat\Javascripts\ program or user directory
// as a .js file to load as Add-In
app.addSubMenu({ cName: "Custom Tools", cParent: "Edit", nPos: 0 });
app.addMenuItem({ cName: "Extract Pages 1-2 with suffix", cParent: "Custom Tools", cExec: "extractPagesWithSuffix()"});
extractPagesWithSuffix = app.trustedFunction(function (){
var re = /.*\/|\.pdf$/ig;
var filename = this.path.replace(re,"");
app.beginPriv();
this.extractPages ({ nStart: 0, nEnd: 0, cPath : filename + "_fill" + ".pdf"});
this.extractPages ({ nStart: 1, nEnd: 1, cPath : filename + "_cut" + ".pdf"});
app.endPriv();
app.alert("Done Extracting Pages 1 & 2 With Suffix!");
})
Regards,
Mike
Copy link to clipboard
Copied
Thanks!!!
What if I want the file to be saved in the Dropbox folder on my Mac?
Copy link to clipboard
Copied
and to delete the page no. 1 in the pdf?
Copy link to clipboard
Copied
Hello aviel222,
Re: What if I want the file to be saved in the Dropbox folder on my Mac?
The extracted pages saved to the Dropbox folder?
Where is your Dropbox folder located on you mac?.....on the desktop?
What is the Hard disk name and your user name?
Regards,
Mike
Copy link to clipboard
Copied
/Users/avielnatan/Dropbox
Copy link to clipboard
Copied
Hello aviel222,
What's the Hard drive name?
???/Users/avielnatan/Dropbox
Do you want the extracted pages to go to the Dropbox folder or the original file after the pages are extracted and page one deleted?
Regards,
Mike
Copy link to clipboard
Copied
Here's how:
The extension _cut will be added to page # 2
Save to the desktop,
And the page 2 will be deleted from the file. And then the document (with page 1) will be saved.
(No need to save first page with _fill extension)
Copy link to clipboard
Copied
Hello aviel222,
What's the Hard drive name?
???/Users/avielnatan/Desktop
re: the document (with page 1)will be saved. saved in it's current location or Dropbox folder?
Regards,
Mike
Copy link to clipboard
Copied
"MacintoshHD"
current location
desktop - better
Thanks!
Copy link to clipboard
Copied
Hello aviel222,
Give this a try......
//Save this in the ....\Acrobat\Javascripts\ program or user directory
// as a .js file to load as Add-In
app.addSubMenu({ cName: "Custom Tools", cParent: "Edit", nPos: 0 });
app.addMenuItem({ cName: "Extract Page 2 with suffix", cParent: "Custom Tools", cExec: "extractPagesWithSuffix()"});
extractPagesWithSuffix = app.trustedFunction(function (){
var re = /.*\/|\.pdf$/ig;
var filename = this.path.replace(re,"");
app.beginPriv();
this.extractPages ({ nStart: 1, nEnd: 1, cPath : "/MacintoshHD/Users/avielnatan/Desktop/" + filename + "_cut" + ".pdf"});
this.deletePages({nStart: 1, nEnd: 1});
app.execMenuItem("Save");
app.endPriv();
app.alert("Done Extracting Page 2 With Suffix!");
})
Regards,
Mike
Copy link to clipboard
Copied
Can you please delete page 2 from the original file? (Of the 2 pages)?
Thanks!!!!!!!
Copy link to clipboard
Copied
the extension must be:
untitled_cut.pdf
not
untitled.ai_cut.pdf
Copy link to clipboard
Copied
Hello aviel222,
That's what the code is doing, I added comments to the code so you can see what it's doing.
I'm not sure why you would save the pdf with the .ai.pdf extention but the code now addresses that.
//Save this in the ....\Acrobat\Javascripts\ program or user directory
// as a .js file to load as Add-In
app.addSubMenu({ cName: "Custom Tools", cParent: "Edit", nPos: 0 });
app.addMenuItem({ cName: "Extract Page 2 with suffix", cParent: "Custom Tools", cExec: "extractPagesWithSuffix()"});
extractPagesWithSuffix = app.trustedFunction(function (){
var re = /.*\/|\.ai.pdf$/ig;
var filename = this.path.replace(re,"");
app.beginPriv();
this.extractPages ({ nStart: 1, nEnd: 1, cPath : "/MacintoshHD/Users/avielnatan/Desktop/" + filename + "_cut" + ".pdf"}); // Extracts page 2 to the desktop with the suffix _cut
this.deletePages({nStart: 1, nEnd: 1}); // deletes page 2 from the original file
app.execMenuItem("Save"); // saves the original file with page 1 only after page 2 is deleted from the original file
app.endPriv();
app.alert("Done Extracting Page 2 With Suffix!");
})
Regards,
Mike
Copy link to clipboard
Copied
thanks a lot!!
Copy link to clipboard
Copied
Hello aviel222,
That's what the code is doing, I added comments to the code so you can see what it's doing.
I'm not sure why you would save the pdf with the .ai.pdf extention but the code now addresses that.
//Save this in the ....\Acrobat\Javascripts\ program or user directory
// as a .js file to load as Add-In
app.addSubMenu({ cName: "Custom Tools", cParent: "Edit", nPos: 0 });
app.addMenuItem({ cName: "Extract Page 2 with suffix", cParent: "Custom Tools", cExec: "extractPagesWithSuffix()"});
extractPagesWithSuffix = app.trustedFunction(function (){
var re = /.*\/|\.ai.pdf$/ig;
var filename = this.path.replace(re,"");
app.beginPriv();
this.extractPages ({ nStart: 1, nEnd: 1, cPath : "/MacintoshHD/Users/avielnatan/Desktop/" + filename + "_cut" + ".pdf"}); // Extracts page 2 to the desktop with the suffix _cut
this.deletePages({nStart: 1, nEnd: 1}); // deletes page 2 from the original file
app.execMenuItem("Save"); // saves the original file with page 1 only after page 2 is deleted from the original file
app.endPriv();
app.alert("Done Extracting Page 2 With Suffix!");
})
Regards,
Mike