S
S
Sergey Nizhny Novgorod2016-11-07 16:49:03
Django
Sergey Nizhny Novgorod, 2016-11-07 16:49:03

Is it possible to simulate printing - save as PDF?

Chrome has a cool feature that allows you to save a page as a PDF - File. In my case it works quite well, the question is: how can this be simulated with Python?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Danil Biryukov-Romanov, 2016-11-07
@urtow

import pdfkit
pdfkit.from_url('http://google.com', 'google.pdf')

On Ubuntu there was this error:
IOError: No wkhtmltopdf executable found: ""
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

After installing wkhtmltopdf, the page was safely saved as pdf

R
Rou1997, 2016-11-07
@Rou1997

It is possible, with the help of a headless browser - Selenium, phantom.js, etc., all that remains is to extract the screenshots, and use the library to link them to PDF.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question