pombreda / xhtml2pdf

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

TypeError: can't multiply sequence by non-int of type 'float' in pisa_tags.py", line 307 #71

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Converting an HTML document with images stored on S3 is throwing the 
following exception for each image:

TypeError: can't multiply sequence by non-int of type 'float'
WARNING:ho.pisa:Error in handling image
u'<img class="" 
src="https://votizen-upvote.s3.amazonaws.com/media/member/pics/299ff13c58.jpg?Si
gnature=CyUhqCCSoYhQr29v%2BK9%2BpuHZr8Y%3D&amp;Expires=1302144546&amp;AWSAccessK
eyId=AKIAIV3FJ7U2F3GO6TNQ"/>'
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/sx/pisa3/pisa_tags.py", line 307, in start
    img.drawWidth *= img.pisaZoom

What is the expected output? What do you see instead?

I expect the images to be processed and included in the PDF.

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

This happened on both OSX and Ubuntu.

Please provide any additional information below.

The problem is with:

                img.drawWidth *= img.pisaZoom
                img.drawHeight *= img.pisaZoom

The 'drawWidth' and 'drawHeight' are both '50px' instead of an int. Maybe 
replace it with the following:

import re

if 'string' == type( img.drawWidth):
  img.drawWidth = float(re.sub('\D', '', img.drawWidth))

if 'string' == type( img.drawHeight):
  img.drawHeight = float(re.sub('\D', '', img.drawHeight))

Original issue reported on code.google.com by mattesnider on 7 Apr 2011 at 2:02

GoogleCodeExporter commented 9 years ago
On your suggestion I would replace the 'string' == type(...) for 
`isinstance(img.drawWidth, basestring)`

Original comment by rafaelh....@gmail.com on 21 Jun 2012 at 8:08