← Back to team overview

sikuli-driver team mailing list archive

[Question #230384]: help with reg.find

 

New question #230384 on Sikuli:
https://answers.launchpad.net/sikuli/+question/230384

Hello, 
im trying to write a short script that will delete blank pages from a pdf using adobe acrobat X standard. it seems to correctly identify blank pages. but for some reason if a blank page is found it deletes every page in the pdf. if i run the script on a 1 page pdf that is not blank it works. the non blank pages have black text on white or blue backgrounds and there are text boxes with red outlines so they are very different from blank pages. 
here is the script

from org.sikuli.script.natives import Vision
Vision.setParameter("MinTargetSize",12)
mmd = Settings.MoveMouseDelay
Settings.MoveMouseDelay = 0.01

def deleteBlankPages(numPages):
    '''
    identifies and deletes blank pages in a pdf
    numPages - integer. the number of pages in the pdf
    '''
    adobe = App('Adobe Acrobat')
    adobe.focus()
    workReg = find("1370615503919.png").above(1).below() # the toolbar area
#    workReg.highlight(3)
    searchReg = find("1370620692978.png").below() # the pdf viewing area 
    searchReg.highlight(3)    
    for i in range(numPages):
        try:
            searchReg.find(Pattern("1370620830920.png").similar(0.90)) # find a blank page pattern 
            type('D', KeyModifier.SHIFT + KeyModifier.CTRL)  # and delete it 
            wait(0.5)
            type(Key.ENTER)
            wait(0.2)
            type(Key.ENTER)
        except FindFailed: # if blank page not found, go to next page
            type(Key.RIGHT)
if __name__ == '__main__':
    deleteBlankPages(8)

thanks in advance for you help

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.