RaptDept / chm2pdf

Automatically exported from code.google.com/p/chm2pdf
GNU General Public License v2.0
0 stars 0 forks source link

"List index out of range" error when CHM contain spaces in internal file structure #43

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1.  Execute chm2pdf on a CHM file that contains spaces in its internal file 
structure.

What is the expected output?

A shiny, new PDF.

What do you see instead?

user@computer ~ $ chm2pdf --book temp.chm
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 318, in convert_to_pdf
    objective_urls=get_objective_urls_list(filename)
  File "/usr/bin/chm2pdf", line 121, in get_objective_urls_list
    urls_list.append(spline[5])
IndexError: list index out of range

What version of the product are you using? On what operating system?

0.9.1 on Linux Mint Debian Edition.

Please provide any additional information below.

A kind fellow named Reto has posted a solution here:

https://groups.google.com/forum/#!topic/chm2pdf/859fW7pSMWA

In get_objective_urls_list of the main script, change the contents of the for 
loop to the following:

for line in flist.readlines()[3:]:
    spline= re.sub(r".*?normal file\s*(.*?)\n$", "\\1", line)
    if spline[0]=="/":
        urls_list.append( spline)
flist.close()

I know little Python and even less CHM, but the fix worked like a charm for me. 
 Now let's see if I can't do something about removing those annoying footers in 
the original CHM...

Thanks for all the time and work that's gone into chm2pdf.  It has already 
helped me out of a tight spot.

Original issue reported on code.google.com by GradyMar...@gmail.com on 26 May 2013 at 1:29