alexandrettio / pyfpdf

Automatically exported from code.google.com/p/pyfpdf
GNU Lesser General Public License v3.0
0 stars 0 forks source link

tuple index out of range #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. pdf.write_html('<h6>This is H6 </h6>')

What is the expected output?
This is H6

What do you see instead?
tuple index out of range

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

Please provide any additional information below.
Change html.py, line 182

        if tag in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6'):
            k = (2, 1.5, 1.17, 1, 0.83, 0.67)[int(tag[1])]
            self.pdf.ln(5*k)
            self.pdf.set_text_color(150,0,0)
            self.pdf.set_font_size(12 * k)
            if attrs: self.align = attrs.get('align')

to:

        if tag in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6'):
            k = (2, 1.5, 1.17, 1, 0.83, 0.67)[int(tag[1])-1]
----------------------------------------------------------^                     

            self.pdf.ln(5*k)
            self.pdf.set_text_color(150,0,0)
            self.pdf.set_font_size(12 * k)
            if attrs: self.align = attrs.get('align')

or more pythonic:

        hsize=dict(h1=2, h2=1.5, h3=1.17, h4=1, h5=0.83, h6=0.67)
        if tag in hsize:
            k = hsize[tag]

Original issue reported on code.google.com by mweis...@gmail.com on 2 May 2013 at 8:45

GoogleCodeExporter commented 9 years ago
This issue was closed by revision bddc3cdba894.

Original comment by reingart@gmail.com on 2 May 2013 at 4:58

GoogleCodeExporter commented 9 years ago
thanks, fixed in rev bddc3cdba894, could you test it?

note that hsize was added as a instance variable, so it could be changed by the 
user.

btw: if you want to send further patches, just attach the diff, so it is easy 
to review, and even I could give you commit access if everithing is ok ;-)

Original comment by reingart@gmail.com on 2 May 2013 at 5:00