In the December Chennaipy meetup, I did my presentation using
asciidoc and
dzslides. Though I liked the output,
with dzslides' CSS it was not possible to print the slides to PDF. I
was looking for ways to convert the slides to PDF, so that I can
upload them to slideshare.
After reading through various projects on the Internet, it occurred to
me that this can be easily done using selenium. The following Python
script opens up the slides, and saves a screenshot of every slide to a
separate image file. The slides are advanced by sending the SPACE key
stroke, to the browser.
from selenium import webdriver
browser = webdriver.Firefox()
browser.set_window_size(1600, 1200)
browser.get("file:///path/to/slides.html")
for i in range(40):
browser.save_screenshot("frame%02d.png" % i)
section = browser.find_element_by_tag_name("section")
section.send_keys(" ")
browser.quit()
The series of screenshots can then be converted to PDF using the
following command.
$ convert frame*.png slides.pdf
Well the result is not perfect, for example, the text is no longer
selectable, in the resulting PDF, and hyperlinks do not work. But I
atleast have something, that can be uploaded to slideshare.
Permalink |
Add Comment |
Share: Twitter, Facebook, Buzz, ... |
Tags: python