Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete blank pages from pdf file

Status
Not open for further replies.

gjbroekhuis

Programmer
Nov 12, 2009
7
NL
Hi,

I have automated Acrobat (COM/OLE), for example for creating a pdf, printing and merging. Is it possible to automate removing all blank pages from a pdf?

Regards, Gerrit
 
I'm not a programmer, but there should be a way for you to access Preflight. (Advanced.../Preflight) Click on the wrench icon to see the options, then click the down arrow under Pages. There's a fix up called "Remove Empty Pages". If I was writing an Applescript, I'd have to use GUI scripting to get to it, but I think Javascript choices are more robust. Check out the SDK at Adobe.com.

Greg
macproductionartist.wordpress.com
 
Hi Gerrit,

if you have automated it using VB, the following code snippet might help you; if you are using C++ or other, you can still use the algorithm of it:
Code:
Dim PDTextS As Acrobat.AcroPDTextSelect
Dim Result As Long, PDDoc As Acrobat.AcroPDDoc
Dim PDPage As Acrobat.AcroPDPage
Dim PDHili As Acrobat.AcroHiliteList
Dim B As Boolean, thePDF As String

Set PDDoc = CreateObject("AcroExch.pdDoc")
    
    Result = PDDoc.Open(thePDF)
    If Not Result Then
        MsgBox "Can't open file: " & thePDF
        Exit Sub
    End If
    [b]
    p = PDDoc.GetNumPages
    For i = 0 To p - 1
        Set PDPage = PDDoc.AcquirePage(i)
        Set PDHili = CreateObject("AcroExch.HiliteList")
        B = PDHili.Add(0, 2000)
        Set PDTextS = PDPage.CreatePageHilite(PDHili)
        
        [red]NTL = PDTextS.GetNumText
        If NTL=0 Then pddoc.DeletePages(i)[/red]
    '...
    '...
    Next i[/b]
    '...
    '...

Something like this?
[pipe]

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Hi,

Something like the following Javascript ought to do what you want.

var numwords = 0;
for (var p = 0; p < this.numPages; p++)
{
numwords = this.getPageNumWords(p);
switch(numwords)
{
case 0:
this.deletePages({nStart: p, nEnd: p});
break;
}
}


In order to understand recursion, you must first understand recursion.
 
Hi Greg,

I don't quite understand your post. We don't do any action in Acrobat, it has to be fully automated. We incorporate the "delete blank pages" function when creating a single pdf document from various pdf documents. Just one mouse click "create" and all the work should be done without any interference or interaction.

For the moment I integrated TiffPdfCleaner in our application, which works quite well.

Regards, Gerrit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top