TransWikia.com

convert a html book to a pdf file?

Unix & Linux Asked on December 10, 2021

How can I convert a html book (consisting of a number of html files linked to each other) to a pdf file on Ubuntu?

Hope the resulting pdf file can have bookmarks according to the structures of the html book.

The html book can be downloaded from here. Extract it, and go to help, and the directory manual is the html book.

4 Answers

Just use wkhtmltopdf

https://github.com/wkhtmltopdf

On my Fedora:

  • install via
    dnf install wkhtmltopdf 
    
  • use as
    wkhtmltopdf in.html out.pdf
    

Answered by alchemist on December 10, 2021

You can use chrome headless

wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
yum localinstall google-chrome-stable_current_x86_64.rpm
./chrome --headless --no-sandbox --disable-gpu --print-to-pdf index.html

Answered by gary69 on December 10, 2021

You can use package htmldoc, which is much easier to get working than pandoc. It takes a list of html files and resolves the hyperlinks between them to produce a single pdf with working links, and includes the images.

htmldoc $(find help/manual -name '*html' | sort) --outfile  /tmp/out.pdf

Of course, it would help to know in what order to collate the html files. I just sorted them on name.

Unfortunately, on my fedora 20 I got core dumps when I tried to put more than half the audacity files through at the same time. I got to 440 pages of output though. Perhaps just not enough memory. YMMV.

Remember for safety to prefer the real audacity web site or your OS package manager rather than sourceforge.

Answered by meuh on December 10, 2021

First off, not sure I can get the bookmarks and such made automatically, as nice as that would be.

You can manually add them, though, afterwards.

Try opening the HTML file in firefox, and going to file -> print (ctrl+p). Then, click "Print to File" and click 'PDF'. Then type your file name and select the folder to save it in.

enter image description here

If you want to automate it, maybe you want wkhtmltopdf? To install it (in ubuntu or debian or linuxmint or similar), type:
sudo apt-get install wkhtmltopdf

Answered by Wyatt Ward on December 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP