jeanphix / Ghost.py

Webkit based scriptable web browser for python.
http://ghost-py.readthedocs.org/en/latest/
2.77k stars 380 forks source link

ghost.capture_to PDF support #14

Closed sebastien closed 9 years ago

sebastien commented 12 years ago

http://code.google.com/p/wkhtmltopdf/ allows to convert HTML to PDF using WebKit -- it would be nice to have a similar feature in Ghost.py

juanriaza commented 11 years ago

+1

philroche commented 11 years ago

+1

carsinger commented 10 years ago

Look here for how to add this method into the Ghost class. https://gist.github.com/jmaupetit/4217925

I modified it just a bit to scale the image.

def capture_pdf(self, filename='ghost.pdf'):
    printer = QPrinter(QPrinter.HighResolution)
    printer.setResolution(300)
    printer.setOutputFileName(filename)
    printer.setPaperSize(QPrinter.Letter)
    printer.setOrientation(QPrinter.Portrait)
    printer.setOutputFormat(QPrinter.PdfFormat)
    painter = QPainter(printer)
    painter.scale(2, 2)
    self.main_frame.render(painter)
    painter.end()
jeanphix commented 9 years ago

http://ghost-py.readthedocs.org/en/latest/#ghost.Ghost.print_to_pdf