Javascript to remove blank pages from PDFs
top of page

Javascript to remove blank pages from PDFs


Evermap has posted the below Javascript here , which is designed to delete blank pages, (blank in the sense that they don't contain any searchable text), from sets of PDFs. I successfully tested the script tonight.

In order to run the script in Adobe Acrobat go to Tools . . . Action Wizard and click 'Create New Action . . . '. Under 'More Tools', in the 'Choose tools to add' section, click on 'Execute Javascript', then uncheck 'Prompt User' and click on 'Specify Settings' on the right. Put the script in the JavaScript Editor . . .

Click OK and save and rename the new action. Add the files you want to process and then click start.

A new file will be created for each source file, with the blank pages removed and '_Original' added to the end of the file name.

// Acrobat JavaScript Code - www.evermap.com // DELETE PDF PAGES WITHOUT TEXT // IMPORTANT: This script assumes that page is blank if it does not contain any "pdf words" // OUTPUT: An output PDF file is created by appending _Original.pdf to the filename try { var newName = this.path; var filename = newName.replace(".pdf","_Original.pdf"); this.saveAs(filename); for (var i = 0; i < this.numPages; i++) { numWords = this.getPageNumWords(i); if (numWords == 0) { // this page has no text, delete it this.deletePages(i,i); } } } catch(e) { app.alert(e); }


Sean O'Shea has more than 20 years of experience in the litigation support field with major law firms in New York and San Francisco.   He is an ACEDS Certified eDiscovery Specialist and a Relativity Certified Administrator.

​

The views expressed in this blog are those of the owner and do not reflect the views or opinions of the owner’s employer.

​

If you have a question or comment about this blog, please make a submission using the form to the right. 

Your details were sent successfully!

© 2015 by Sean O'Shea . Proudly created with Wix.com

bottom of page