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.

  • 1
    Have you taken a look at pandoc? It manages to convert between tons and tons of things (including PDF and HTML). – HalosGhost Jun 24 '15 at 3:45
  • thanks. how shall I use pandoc to convert? – Tim Jun 24 '15 at 3:46
  • Their documentation should take care of that :) – HalosGhost Jun 24 '15 at 4:07
  • thanks. in the extracted directory from the zip file, the html book is in the directory help/manual. Its first page is index.html, which contains links to a lot of other htmls in directory help/manual/man. Do I have to specify all the html files as inputs to pandoc, or just index.html and no other html files as input to pandoc? If the former, how do you specify the many html files in the correct order? – Tim Jun 24 '15 at 4:15
  • That is a good question of which I know not the answer. Though I know of pandoc, I have never personally had a need to use it. – HalosGhost Jun 24 '15 at 4:20

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

| improve this answer | |
  • wkhtmltopdf was perfect! – niCk cAMel Jan 3 at 13:24
  • Great! Glad my answer helped someone, all these years later. I'd totally forgotten writing this answer… – Wyatt8740 Jan 4 at 11:06

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.

| improve this answer | |

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
| improve this answer | |
  • There are multiple html files, and index.html might just be the one with links to the others. Will your chrome command only print the index.html or also the html files linked from it? – Tim Apr 22 at 11:41
  • I've actually only tried it with 1 html file – gary69 Apr 23 at 2:53

Just use wkhtmltopdf


On my Fedora:

  • install via
    dnf install wkhtmltopdf 
  • use as
    wkhtmltopdf in.html out.pdf
| improve this answer | |
  • Welcome to the site, and thank you for your contribution. Please note that using wkhtmltopdf was already suggested in this answer by @Wyatt8740; you may want to edit yours to make the difference clearer. – AdminBee Jul 23 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.