DevHeads.net

Best command line tool to convert a webpage to a pdf file?

Hi, I have tried wkhtmltopdf. But it can not always guarantee to
generate the pdf correctly. Does anybody know a tool that can generate
a pdf from a URL reliably?

Comments

Re: Best command line tool to convert a webpage to a pdf file?

By Oliver Grawert at 02/12/2018 - 06:04

hi,
Am Freitag, den 09.02.2018, 20:49 -0600 schrieb Peng Yu:
yes, libreoffice can do that easily ...

libreoffice.writer --headless --norestore --writer \
  --convert-to pdf $URL

but note that there is no way to define the output filename, it will
use the name of the input file, so if your URL ends in / you end up
with a file just called ".html" (you probably want to wrap a script
around the line above to give the file a proper name)

ciao
oli

Re: Best command line tool to convert a webpage to a pdf file?

By R Kimber at 02/12/2018 - 09:03

On Mon, 12 Feb 2018 11:04:35 +0100

I'm using Version: 5.1.6.2 on 16.04.3 and for that, at least, it needs
to be:

libreoffice --headless --norestore --writer  --convert-to pdf $URL

- Richard

Re: Best command line tool to convert a webpage to a pdf file?

By Michael Welle at 02/10/2018 - 03:15

Hello,

Peng Yu <pengyu. ... at gmail dot com> writes:

currently I'm experimenting with changing my slide producing process
from Org -> PDF -> HTML to Org -> HTML -> PDF. For the last step
<a href="https://github.com/astefanutti/decktape" title="https://github.com/astefanutti/decktape">https://github.com/astefanutti/decktape</a> looks promising. I use the
pre-prepared docker container.

Regards
hmw

Re: Best command line tool to convert a webpage to a pdf file?

By Peter Flynn at 02/10/2018 - 16:45

On 10/02/18 07:15, Michael Welle wrote:
Install the Vivaldi browser. It has a neat capture facility designed for
screenshotting which creates a JPG or PNG from the *whole* page (ie tall
and narrow)...but then it's easy to cut it up and make a PDF.

It won't of course be a real typeset PDF...for that you would indeed
have to use a renderer like *htmltopdf but the problem is that they are
really not enabled for modern HTML5 pages: the markup is simply too sloppy.

///Peter

Re: Best command line tool to convert a webpage to a pdf file?

By NoOp at 02/11/2018 - 22:00

On 02/10/2018 12:45 PM, Peter Flynn wrote:
Also not CLI, but:

Opera Browser
Version information
Version: 51.0.2830.26 - Opera is up to date
Update stream: Stable
System: Ubuntu 16.04.3 LTS (x86_64; GNOME-Flashback:Unity)

Page|Save as PDF

Does a nice job of saving to a single page PDF.

opera-stable:
Installed: 51.0.2830.26
Candidate: 51.0.2830.26
Version table:
*** 51.0.2830.26 500
500 <a href="https://deb.opera.com/opera-stable" title="https://deb.opera.com/opera-stable">https://deb.opera.com/opera-stable</a> stable/non-free amd64
Packages
100 /var/lib/dpkg/status

Opera comes in a pre-packaged deb: <a href="https://www.opera.com/" title="https://www.opera.com/">https://www.opera.com/</a> and will
automatically set up the deb.opera.com repository for updates upon install.

Re: Best command line tool to convert a webpage to a pdf file?

By Bret Busby at 02/12/2018 - 03:06

On 12/02/2018, NoOp < ... at sbcglobal dot net> wrote:
I wrote off Opera when the norsemen sold it to the chinese government
so they could use it for their nefarious purposes.

Up until then, it was reputed to be the most secure GUI web browser.