Is there some program which can convert a html ebook (consisting of many html files located under different directories and linked to each other) to a pdf file? For example, some shell scripting (e.g. in bash) which calls some program that does the conversion?

Additionally, if possible, can the resulting pdf file have outlines/bookmarks for clicking and jumping, according to the structures of the html book?

An example of a html ebook can be downloaded from http://en.cppreference.com/w/Cppreference:Archives. Extract it, and there are several levels of subdirectories. At the root level, there is a file cppreference-doxygen-local.tag.xml which seems to list all the html files, and might be helpful for convertion to a pdf file.


  • You can take a look here princexml.com
    – maxwell
    Commented Aug 13, 2017 at 14:25
  • Seems like converting these manuscripts programmatically is a req. from the bash reference
    – maxwell
    Commented Aug 13, 2017 at 14:26
  • Thanks. What do you mean by "a req from the bash reference"?
    – Tim
    Commented Aug 13, 2017 at 14:57
  • A requirement to an adequate solution
    – maxwell
    Commented Aug 13, 2017 at 14:57
  • 1
    Why do you want to end up with a PDF that won't wrap text to different screen sizes? If you really want this, look at Pandoc. It can read html and "It can also produce PDF output on systems where LaTeX, ConTeXt, or wkhtmltopdf is installed." Pandoc runs on several operating systems.
    – Bulrush
    Commented Aug 16, 2017 at 18:38

2 Answers 2


Let me tell you the easiest way: you could paste the entire contents from the browser into a MS word/Libre Office file and then export to PDF. Both programs are fairly good at importing HTML -- they are just lousy at exporting to HTML. If you made sure that all H1 titles were mapped to a single style in the office program, you could either generate a TOC at the top or permit an outline view inside the PDF. It's unlikely that any of the original HTML links will work though.

There are other ways to do it -- using GUI tools like Calibre or Sigil. You could also try the open source WKHTMLTOPDF (which I haven't tried yet).

UPDATE: I just looked at the content you are trying to store. This is structured technical reference material; probably not a good candidate for the cut and paste solution I recommended and not good viewing for PDF. You probably need to store the html files on your device so that an app like Android's Offline Browser can view it. I just tried viewing your web URL in Offline browser, and it probably is what you're looking for. It stores in offline mode on your android device the site, with lots of ways to configure it (depth of links, number of links, etc).


Let me introduce you to a service (with a free option) that I'm just investigating myself. Please note that I am NOT an employee of this company, nor a reseller, nor in anyway affiliated with them. I'm just passing along a resource I discovered that has the potential of being really, really, really valuable (though not really, really, really tested yet. I'm working on that).


These folks convert almost anything to anything, including HTML to PDF. It has an API if you're tring to automate, and a dashboard if you're looking for a one-off. You do need to sign up to use the service, free or not. With a free option, it can't hurt to give them a try and see what they can do for you.

  • As with any cloud service you should never ever use this, if your content is, and should stay, private.
    – Anthon
    Commented Aug 22, 2017 at 10:07

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