Scroll a PDF with Selenium python

Viewed 71

I'm trying to scroll through a PDF with Selenium but It doesn't appear to be working.

The code I'm working with is a little in depth but here's the crucial bits.

    driver = webdriver.Firefox()

    driver.maximize_window()
    driver.get("http://scop-qb.org/wp-content/uploads/SCOP-B-Round-2.pdf")


    for rectangle in rectangles:
        if not previous is None:
            driver.execute_script("window.scrollTo({0}, {1})".format(rectangle[0], rectangle[1]))

I've been searching for a solution all night, if anyone could help that'd be great.

1 Answers

An alternative would be to chain a bunch of down-arrow keys or spacebars together:

driver.get("http://scop-qb.org/wp-content/uploads/SCOP-B-Round-2.pdf")
time.sleep(1)
actions = ActionChains(driver)
for _ in range(3): # Adjust for how far down the page you want
    actions.send_keys(Keys.ARROW_DOWN).perform()
Related