Ubuntu Geek

Ubuntu Linux Tutorials,Howtos,Tips & News | Gutsy,Hardy,Intrepid

  • RSS Feed

    subscribe to the ubuntu Geek RSS feed

  • Follow Us on Twitter

  • Sponsor


  • Categories

  • Meta

  • Sponsor

  • Archives

  • Support Ubuntugeek

    Amount $:
    Website(Optional):


  • Favourite Sites

How to convert CHM files into PDF files in Ubuntu

Posted by admin on June 27th, 2008 Email This Post Email This Post

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

If you want to convert .chm file to .pdf file you need to install chm2pdf application.This is A Python script that converts CHM files into PDF files. The package supports batch conversion, command line, PDF security options, password protection and compression modes. The program has Explorer-like interface.

Install chm2pdf in ubuntu

sudo aptitude install chm2pdf

Using chm2pdf

chm2pdf syntax

/usr/bin/chm2pdf [options] input_filename [output_filename]

chm2pdf examples

Unstructured HTML files inside the CHM file, use of --webpage option - produces my-file.pdf:

chm2pdf --webpage my-file.chm

Structured HTML files:

chm2pdf --book my-file.chm

Structured HTML files, produce a table of contents page automatically (--title option):

chm2pdf --book --title my-file.chm

Structured HTML files, produce a table of contents page automatically (--title option), add a “titlepage” as found in the toc.html file inside the CHM:

chm2pdf --book --title --titlefile toc.html my-file.chm

If the file “toc.html” is not found, a warning will be issued and the option will be ignored - just browse the (very verbose) output of chm2pdf to see that warning if you suspect you mispelled the titlefile name.

Like above, now with an explicitly set page size and maximum compression level for the resulting PDF:

chm2pdf --book --title --titlefile toc.html --size 177.8×233.3mm --compression 9 my-file.chm

Like above, but name the PDF “your-file.pdf”:

chm2pdf --book --title --titlefile toc.html --size 177.8×233.3mm --compression 9 my-file.chm your-file.pdf

A very interesting option (and one that is not htmldoc-specific, but is pure chm2pdf-specific) is the --extract-only option:

chm2pdf --extract-only my-file.chm

will extract the contents of my-file.chm (all the HTML and other, “special”, files inside the CHM) into the directory CHM2PDF_TEMP_ORIG_DIR/my-file. Thus, if CHM2PDF_TEMP_ORIG_DIR has its default value “/tmp/chm2pdf/orig”, chm2pdf will extract the file into /tmp/chm2pdf/orig/my-file and stop. You can then examine the extracted files at your pace. They will be overwritten next time you call chm2pdf with the same file(name).

If you want to know more available options use the following command from your terminal

chm2pdf --help

Share/Save/Bookmark

Related Articles

5 Responses to “How to convert CHM files into PDF files in Ubuntu”

  1. Steve Says:

    YES!

    A million thanks to whoever packaged this for Ubuntu/Debian!

  2. Bytevic Says:

    I have Ubuntu 7.10, and the ch2pdf package doesn’t exists, The solution? Easy:

    First install this packages:

    sudo aptitude install libchm-bin libchm-dev htmldoc python-chm

    Second

    Download de chm2pdf script on this site: http://code.google.com/p/chm2pdf/

    Thanks for the tip :D

  3. Shakhaoat Says:

    great help man.
    thnx.
    with your permission, can I post the link of this webpage in my blog?

  4. admin Says:

    yes you can post the source link

  5. Shakhaoat Says:

    thnx.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>