Copy link to clipboard
Copied
I am trying to figure out a way to batch process to remove the last page of documents automatically and have DC identify it without me having to add the individual page numbers toi delete.
You can do it using this code:
this.deletePages(this.numPages-1);
Copy link to clipboard
Copied
[moved from ActionScript 3 to Editing & Exporting PDFs]
Copy link to clipboard
Copied
You can do it using this code:
this.deletePages(this.numPages-1);
Copy link to clipboard
Copied
Where do I put this and how do I apply it. I have never seen anything like this and I'm in the New Custom Command and ????
Copy link to clipboard
Copied
No, you need to go to Tools - Action Wizard and then create a new Action.
Add to it an "Execute JavaScript" command (from the More Tools section) and a Save command (from the Save and Export section).
Open the first command and then click on Specify Settings. Paste the code I provided above into the window that opens and click OK.
Make sure to un-tick the "Prompt User" check-box underneath it.
Now save your Action and you can run it from the Action Wizard by clicking it. Select which files/folders to process and click on Start.
Be aware that this process is NOT reversible, so make sure you have a backup of your files before running it, just in case of any problems.
PS. Use this code, actually, or you'll get an error message for files with just one page:
if (this.numPages>1) this.deletePages(this.numPages-1);
Copy link to clipboard
Copied
try67​ Thanks for this! MAN! We've been trying to figure this out for days now!!!! Just one thing.. the sting you added at the bottom. This last line to your post:
if (this.numPages>1) this.deletePages(this.numPages-1);
Do we copy and paste it in the same way as we did:
this.deletePages(this.numPages-1);
because we tried it and it didn't work. Wondering what we're doing wrong?!?!
Copy link to clipboard
Copied
Yes, you use it exactly the same. What happens when you try to use it?
Copy link to clipboard
Copied
Open the JavaScript debugging console in Acrobat and see if there are any errors.
If the PDFs have security applied you may need to remove that security before running the script.
Copy link to clipboard
Copied
How can I teak this code to delete only first page?
I have 3 pages in each pdf. I just want to delete the first page.
Please Help.
Thank you,
Sumana
Copy link to clipboard
Copied
Delete the first page:
if (this.numPages > 1) this.deletePages({nStart: 0});
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Delete from page 10 to last page:
if (this.numPages > 9) this.deletePages({nStart: 9, nEnd: this.numPages-1});
Copy link to clipboard
Copied
Hello, thank you for the info. What would be the command line to delete the last 2 pages of pdfs? Thank you in advance
Copy link to clipboard
Copied
if (this.numPages > 3) this.deletePages({nStart: this.numPages-2, nEnd: this.numPages-1});
Copy link to clipboard
Copied
Thank you so much. HAPPY HOLIDAYS.!