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

How do you delete pages but suppess prompt? Or Automate Delete?

Registered: Nov 2 2011
Posts: 7

Hello,
This is my first post. I often have to quickly go through a 50 to several hundred page document manually and delete any pages I that meet some critera. I use page view and just click each page, look at it for a sec, decide if I want to delete it or not. It slows things down greatly, if every single time I need to delete a page, it asks me -
 
-What page I want to delete. I dont understand this, I only highlighted (clicked) that one page in the page view. Why is it asking me this again? Anyway, how could I bypass this message?
 
-It then asks me a second question - Are you sure you want to delete that page? Really really really sure? Ugh, is there some way I can shut this prompt off?
 
So many features or lack of, it seams like Adobe has almost intentionally left obvious things out.
 
What would be ideal is if I could just click on a page and drag it to a trash can real quick. What a timesaver that would be, but I guess in 2011 we dont have the technology do do that yet :| Does anyone know of a way to do this or similar?
 
If not too above, I imagine Adobe most offer a program for sale that does something like this, a page managment add on that allows you to quickly manipulate the pages. I am just talking basic, just move delete the page as selected with no prompts.
Any help appreciated.

My Product Information:
Acrobat Pro 9.4.3, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
You can create a custom toolbar button with a bit of JavaScript that can delete the current page.

For more information, see the doc.deletePages documentation: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.452.php

For more information on creating a custom toolbar button, see: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.134.php

If you get stuck, post again and someone will help.
Registered: Nov 2 2011
Posts: 7
Thank for the post. I cant really afford the time to learn java script then do the tool bar, but its good to know that someday, acrobat would could be more useful. Also, what does "Accept this answer" actually do? Is this for bragging rights or compensation?
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Someone might post the script, so stay tuned.

Regarding the "Accept this answer" question, it's for neither of those reasons. Rather, it lets others who may stumble across this know what the correct answer is.
Registered: Nov 2 2011
Posts: 7
I would love it if someone posted a script or scripts to use as tool. It would take me awhile to learn where to put them in Acrobat. I did some browsing and saw Javascript things in the Advanced Tab under Document Processing (Acrobat 9 pro)

Good idea about the accept answer feature. I will say this about Adobe, I do have the best looking, most readable scanned documents. I just dont find their interface that intuitive but hopefully that improves for me. Anyway, If I can get the script features working it would be a major time saver.
Thank You
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Below is the script that you have to add to a folder-level JavaScript file that you then have to install on your system. This process is discussed in the following tutorial: http://acrobatusers.com/tutorials/2006/folder_level_scripts

If you're using Acrobat 10.1.1, the folder location for JavaScripts has changed, so post again if this is the case.

Once you install the script and relaunch Acrobat, you will have a toolbar button that will become active when you have a normal PDF (not an XFA form) loaded that has more than one page. If the document has security restrictions that prevent pages from being deleted, you'll get an error message. When you click the toolbar button, the page will get immediately deleted without warning or the ability to undo. If using Acrobat 10, you'll have to find the toolbar button in one of the panels under the Tools pane, I forget which one. It can be dragged to the Quick Tools area of the toolbar.

Post again if you need help getting it to work.

  1. // Place the following code in a folder-level JavaScript file
  2. var deleteCurrentPage = function(doc) {
  3.  
  4. // Delete the current page
  5. try {
  6. doc.deletePages(doc.pageNum);
  7. } catch(e) {
  8. app.alert("Could not delete page, probably because the document is secured.", 3);
  9. }
  10. };
  11.  
  12. app.addToolButton(
  13. {
  14. cName: "Delete_Current_Page",
  15. cLabel: "Delete Page",
  16. cExec: "deleteCurrentPage(this);",
  17. cEnable: "event.rc = (app.doc && numPages > 1 && (typeof xfa === \"undefined\"));"
  18. }
  19. );
Registered: Nov 2 2011
Posts: 7
George,
Thank you very much. I doesnt quite work but I think I am very close. I have never worked with Javascript and Adobe. I created put the code above in to word, saved it as somefile.js and then copied that file to the locals folder location and th global folder location. I restarted Acrobat and open a pdf. The "Delete File" button shows up, but it is greyed out. What do you think I should do? Thx again for making that program.
Registered: Nov 2 2011
Posts: 7
Just wanted to give an updated. Using the debugger I get this message-


Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0

GeneralError: Operation failed.
App.addToolButton:15:Folder-Level:User:DVel.js
The name for the toolbutton must be unique
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
That's odd. Try changing the line that sets the name to:

cName: "ir4951_Delete_Current_Page",

or something like that. It doesn't really matter what you call it, but it does have to be unique.


The button should be greyed out until you open a document that has more than one page.
Registered: Nov 2 2011
Posts: 7
Sorry for taking so long getting back here. The button is greyed out. I changed the name to something else but no luck. Any ideas?
Thank YOu
Registered: Nov 2 2011
Posts: 7
I thought I would give an update. I got lucky and tried a tip - The code works perfectly I just needed to go to Edit-Preferences-Documents-View PDA set to "Never"

Not sure what that does but the buttons appears after that. Thanks again for the code, it is very useful