My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
HowToUse  
Usage of chm2pdf
Featured
Updated Feb 4, 2010 by devicera...@gmail.com

Usage:

/usr/bin/chm2pdf (--book / --webpage) [options] input_filename [output_filename]

Either '--book' or '--webpage' MUST be given! Only one of the two options can be present, not both!

chm2pdf supports most command line htmldoc options. For a full summary usage, type chm2pdf --help at the command line.

PLEASE DO NOT POLLUTE THIS WIKI PAGE WITH COMMENTS If you have trouble using chm2pdf, use the Google group instead.

Comment by nick.hri...@gmail.com, Sep 21, 2007

Do not forget to use the --enable-examples on chmLib, otherwise this script will throw a bunch of exceptions, and will fail.

If you have a mac, and you use darwin ports (port on the cmdline), be aware that the chmlib will NOT be built with this option. You can, however, separately download chmlib and build it yourself with this option, install it, and then re-run the script.

Comment by pieterva...@gmail.com, Sep 29, 2007

make sure you have python-chm bindings installed !!!

or you get an error like

File "/usr/bin/chm2pdf", line 11, in <module>
import chm.chm as chm
ImportError?: No module named chm.chm

Comment by segolas....@gmail.com, Oct 25, 2007

On my ubuntu Feisty this is what I obtain:

Traceback (most recent call last):

File "/usr/bin/chm2pdf", line 176, in <module>
main(sys.argv)
File "/usr/bin/chm2pdf", line 172, in main
convert_to_pdf(cfile, filename, outputfilename)
File "/usr/bin/chm2pdf", line 106, in convert_to_pdf
pf=open(page_filename,'r')
IOError: 2? No such file or directory: '../tempout//final/toc.html'

think the error is in the last line, that double slash "//".

I try to fix it but still got the same... it seems it don't create the tempout directory :-(

Comment by ppereva...@gmail.com, Oct 27, 2007

On Ubuntu box if you are getting following error

OError: 2? No such file or directory: '../tempout//final/toc.html' and chm2pdf complaains about libchm.so.0 run the command below:

sudo ln -s /usr/local/lib/libchm.so.0 /usr/lib/libchm.so.0

Comment by henry.ju...@gmail.com, Nov 6, 2007

START-QUOTE

On my ubuntu Feisty this is what I obtain:

Traceback (most recent call last):

File "/usr/bin/chm2pdf", line 176, in <module>
main(sys.argv)
File "/usr/bin/chm2pdf", line 172, in main
convert_to_pdf(cfile, filename, outputfilename)
File "/usr/bin/chm2pdf", line 106, in convert_to_pdf
pf=open(page_filename,'r')

IOError: 2? No such file or directory: '../tempout//final/toc.html'

think the error is in the last line, that double slash "//".

I try to fix it but still got the same... it seems it don't create the tempout directory :-(

END-QUOTE

Me too. I obtain the same error on Suse 10.1

Comment by henry.ju...@gmail.com, Nov 6, 2007

I have done sudo ln -s /usr/local/lib/libchm.so.0 /usr/lib/libchm.so.0 but the situation is unchanged. Anyway, chm2pdf doesn't complains about libchm.so.0 .

Quilos did you solved the problem '../tempout//final/toc.html' ?

Comment by blub...@gmail.com, Nov 6, 2007

On Ubuntu, open the chm2pdf.py file using your favourite editor and search for or scroll down to the

    #concatenation

Section and change the code to

    print 'Concatenating '+str(c)+' individual PDF files...'
    os.system("pdftk *.pdf cat output "+outputfilename)

Re run the setup and It Works like a charm ;)

Comment by henry.ju...@gmail.com, Nov 6, 2007

To bluboy. On Suse, this doesn't solve my problem.

Comment by Halil.Se...@gmail.com, Nov 13, 2007

I ve got this in the last line:

IOError: 2? No such file or directory: '../tempout//./HTML/pic1.jpg'

Comment by manuel.p...@gmail.com, Nov 19, 2007

Please make chm2pdf inform you when the commands enum_chmLib and htmldoc are not available.

I've got "IOError: No such file or directory" because enum_chmLib wasn't in the system. Before installing libchm-dev it finished printing "Done" at the end, but no pdf was there, because htmldoc wasn't found. After installing htmldoc all was fine.

Comment by doc...@gmail.com, Dec 4, 2007

On Opensuse 10.3, I installed chm2pdf and chmlib (from source with --enable-example), pychm (I extract the tarball in /) and htmldoc (from suse repository), but it appers:

# chm2pdf Traceback (most recent call last):

File "/usr/local/bin/chm2pdf", line 24, in <module>
import chm.chm as chm
ImportError?: No module named chm.chm

Thanks

Comment by chenh...@gmail.com, May 7, 2008

On ubuntu7, I got HTMLDOC window, when I click the button 'Generate', it prompts "No HTML files to format, cannot generate document". Can anyone tell me what is wrong?

Thanks

Comment by fredrik....@gmail.com, Jun 27, 2008

I'm on Ubuntu Gutsy 7.10. Followed the nice walkthrough for Ubuntu and managed to convert a 1000+ pages CHM correctly. However subsequent conversions all failed with "no pages generated", but next line says "Written file blah.pdf". Tried to remove /tmp/chm2pdf before conversion - no luck. Also the script cannot parse filenames with blanks even when specified like so: "filename with blank.chm"

Comment by joseph.h...@gmail.com, Nov 11, 2008

On Ubuntu 8.04, I also had an error "OError: 2? No such file or directory:..."; the workaround for this problem is to change the .CHM file name to a simpler form (i.e. no dots before ".chm" and no spaces within the file name), and it worked. one thing that was little bit odd was --book did not work, but --webpage worked.

Thank you for making chm2pdf available

Comment by usman...@gmail.com, Jan 4, 2009

yes joseph your solution is right , it is working chm2pdf --webpage filename.chm there should be no spaces in file name . Thanks a lot Usman ali

Comment by meta.log...@gmail.com, Jan 24, 2009

Haven't seen a script containing this many obvious bugs. Code itself is well... not clean, to say the least.

This thing needs a complete rewrite, I suppose.

Comment by thomcmar...@gmail.com, Mar 7, 2009

This script works just fine. You just need to run the script without any spaces in the file name.

Comment by ghe...@gmail.com, Mar 7, 2009

On Debian Lenny

[root] [/home/nercof/Desktop]$ chm2pdf --book OReilly.Twisted.Network.Programming.Essentials.Python.Oct.2005.chm OReilly.Twisted.Network.Programming.Essentials.Python.Oct.2005.pdf
rm: no se puede borrar «/tmp/chm2pdf/orig/OReilly.Twisted.Network.Programming.Essentials.Python.Oct.2005/*»: No existe el fichero o el directorio
rm: no se puede borrar «/tmp/chm2pdf/work/OReilly.Twisted.Network.Programming.Essentials.Python.Oct.2005/*»: No existe el fichero o el directorio
sh: /tmp/chm2pdf/work/OReilly.Twisted.Network.Programming.Essentials.Python.Oct.2005/urlslist.txt: No existe el fichero o el directorio
Traceback (most recent call last):
  File "/usr/bin/chm2pdf", line 1111, in <module>
    main(sys.argv)
  File "/usr/bin/chm2pdf", line 1107, in main
    convert_to_pdf(cfile, filename, outputfilename, options)
  File "/usr/bin/chm2pdf", line 326, in convert_to_pdf
    objective_urls=get_objective_urls_list(filename)
  File "/usr/bin/chm2pdf", line 114, in get_objective_urls_list
    flist=open(CHM2PDF_WORK_DIR+'/urlslist.txt','rU')
IOError: [Errno 2] No such file or directory: '/tmp/chm2pdf/work/OReilly.Twisted.Network.Programming.Essentials.Python.Oct.2005/urlslist.txt'
[root] [/home/nercof/Desktop]$ 

which may be the problem?

Comment by manish.m...@gmail.com, Apr 20, 2009

on Ubuntu 9.04

manish@manish-laptop:~$ /usr/bin/chm2pdf --book '/home/manish/Desktop/a.chm' a.pdf Traceback (most recent call last):

File "/usr/bin/chm2pdf", line 1098, in <module>
main(sys.argv)
File "/usr/bin/chm2pdf", line 1092, in main
convert_to_pdf(cfile, filename, outputfilename, options)
File "/usr/bin/chm2pdf", line 386, in convert_to_pdf
correct_file(page_filename, htmlout_filename, html_list, objective_urls, options)
File "/usr/bin/chm2pdf", line 131, in correct_file
pf=open(input_file,'rU')
IOError: 21? Is a directory: '/tmp/tmp8V56Zx/a/' manish@manish-laptop:~$ /usr/bin/chm2pdf --webpage '/home/manish/Desktop/a.chm' a.pdf Traceback (most recent call last):
File "/usr/bin/chm2pdf", line 1098, in <module>
main(sys.argv)
File "/usr/bin/chm2pdf", line 1092, in main
convert_to_pdf(cfile, filename, outputfilename, options)
File "/usr/bin/chm2pdf", line 386, in convert_to_pdf
correct_file(page_filename, htmlout_filename, html_list, objective_urls, options)
File "/usr/bin/chm2pdf", line 131, in correct_file
pf=open(input_file,'rU')
IOError: 21? Is a directory: '/tmp/tmpU5qsF8/a/'

what is the problem?

Comment by amareshchandradas2005, May 7, 2009

as per this given link

"http://www.karakas-online.de/forum/viewtopic.php?t=10275" i worked but i
am facing bellow error, 1>chm2pdf --book my-file.chm

root@AmSi?:/home/amaresh/Desktop# chm2pdf --book Glass\,Ables\ -\ Linux\ for\ Programmers\ and\ Users\ \(Prentice\,\ 2006\).chm CHM2PDF_WORK_DIR = /tmp/chm2pdf/work/Glass,Ables - Linux for Programmers and Users (Prentice, 2006) CHM2PDF_ORIG_DIR = /tmp/chm2pdf/orig/Glass,Ables - Linux for Programmers and Users (Prentice, 2006) Removing any previous temporary files sh: Syntax error: "(" unexpected sh: Syntax error: "(" unexpected sh: Syntax error: "(" unexpected sh: Syntax error: "(" unexpected Traceback (most recent call last):

File "/usr/bin/chm2pdf", line 887, in <module>
main(sys.argv)
File "/usr/bin/chm2pdf", line 883, in main
convert_to_pdf(cfile, filename, outputfilename, options)
File "/usr/bin/chm2pdf", line 180, in convert_to_pdf
objective_urls=get_objective_urls_list(filename)
File "/usr/bin/chm2pdf", line 98, in get_objective_urls_list
flist=open(CHM2PDF_WORK_DIR+'/urlslist.txt','r')
IOError: 2? No such file or directory: '/tmp/chm2pdf/work/Glass,Ables - Linux for Programmers and Users (Prentice, 2006)/urlslist.txt'

Waiting for solution,

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


root@AmSi?:/home/amaresh/Desktop# chm2pdf --book --title Glass\,Ables\ -\ Linux\ for\ Programmers\ and\ Users\ \(Prentice\,\ 2006\).chm CHM2PDF_WORK_DIR = /tmp/chm2pdf/work/Glass,Ables - Linux for Programmers and Users (Prentice, 2006) CHM2PDF_ORIG_DIR = /tmp/chm2pdf/orig/Glass,Ables - Linux for Programmers and Users (Prentice, 2006) Removing any previous temporary files sh: Syntax error: "(" unexpected sh: Syntax error: "(" unexpected sh: Syntax error: "(" unexpected sh: Syntax error: "(" unexpected Traceback (most recent call last):
File "/usr/bin/chm2pdf", line 887, in <module>
main(sys.argv)
File "/usr/bin/chm2pdf", line 883, in main
convert_to_pdf(cfile, filename, outputfilename, options)
File "/usr/bin/chm2pdf", line 180, in convert_to_pdf
objective_urls=get_objective_urls_list(filename)
File "/usr/bin/chm2pdf", line 98, in get_objective_urls_list
flist=open(CHM2PDF_WORK_DIR+'/urlslist.txt','r')
IOError: 2? No such file or directory: '/tmp/chm2pdf/work/Glass,Ables - Linux for Programmers and Users (Prentice, 2006)/urlslist.txt'

Comment by Piet.Ruy...@gmail.com, Jun 2, 2009

chm2pdf works fine for me for simple filenames like myfile.chm It does give problems for file that are name like Linux for programmers that use brackets like ( and ) and spaces in their filenames.chm Just rename your chm-file first

Comment by bicivili...@gmail.com, Jul 1, 2009

The cause of error:


failed to open Web Traceback (most recent call last):
File "/usr/bin/chm2pdf", line 1098, in <module> ....

is the name of the chm file, i.e, Book Test.chm....the correct name should be: BookTest?.chm, otherwise chm2pdf dont't work.

Comment by kalge...@gmail.com, Oct 14, 2009

i'm getting the following error: bash-3.1# chm2pdf --book book.chm rm: cannot remove `/tmp/chm2pdf/orig/book/': No such file or directory rm: cannot remove `/tmp/chm2pdf/work/book/': No such file or directory sh: /tmp/chm2pdf/work/book/urlslist.txt: No such file or directory Traceback (most recent call last):

File "/usr/bin/chm2pdf", line 1111, in <module>
main(sys.argv)
File "/usr/bin/chm2pdf", line 1107, in main
convert_to_pdf(cfile, filename, outputfilename, options)
File "/usr/bin/chm2pdf", line 326, in convert_to_pdf
objective_urls=get_objective_urls_list(filename)
File "/usr/bin/chm2pdf", line 114, in get_objective_urls_list
flist=open(CHM2PDF_WORK_DIR+'/urlslist.txt','rU')
IOError: 2? No such file or directory: '/tmp/chm2pdf/work/book/urlslist.txt' don't know what's the problem

Comment by barss....@gmail.com, Apr 27, 2010

Just create these directories You need both /tmp/chm2pdf/orig/book/ and /tmp/chm2pdf/work/book/ for your example

Comment by Defc...@gmail.com, Jun 11, 2011

This script is lame. Gunna just do it at work in windows.

Comment by david.ro...@ge.com, Apr 19, 2012

I tried the chm2pdf pilot. Produced PDF, but w/o a Table of contents. Is this as expected? Does the latest, retail version produce a TOC?


Sign in to add a comment
Powered by Google Project Hosting