• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

extract 2 pages in pdf for 2 separate files

Explorer ,
Jan 30, 2021 Jan 30, 2021

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!!!

TOPICS
JavaScript

Views

3.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Feb 01, 2021 Feb 01, 2021

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
...

Votes

Translate

Translate
Advisor ,
Jan 31, 2021 Jan 31, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 31, 2021 Jan 31, 2021

Copy link to clipboard

Copied

Thanks!!!

What if I want the file to be saved in the Dropbox folder on my Mac?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 31, 2021 Jan 31, 2021

Copy link to clipboard

Copied

and to delete the page no. 1 in the pdf?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 31, 2021 Jan 31, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 31, 2021 Jan 31, 2021

Copy link to clipboard

Copied

/Users/avielnatan/Dropbox

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 31, 2021 Jan 31, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2021 Feb 01, 2021

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 01, 2021 Feb 01, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2021 Feb 01, 2021

Copy link to clipboard

Copied

"MacintoshHD"

 

current location

desktop - better

 

Thanks!

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 01, 2021 Feb 01, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2021 Feb 01, 2021

Copy link to clipboard

Copied

Can you please delete page 2 from the original file? (Of the 2 pages)?

Thanks!!!!!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2021 Feb 01, 2021

Copy link to clipboard

Copied

the extension must be:

untitled_cut.pdf

 

not

untitled.ai_cut.pdf

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 01, 2021 Feb 01, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2021 Feb 01, 2021

Copy link to clipboard

Copied

LATEST

thanks a lot!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 01, 2021 Feb 01, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines