bzr revid: dsh@tinyerp.com-20090522071634-uqui7cyb2g9jal78
This commit is contained in:
dsh (Open ERP) 2009-05-22 12:46:34 +05:30
parent 94ad944c20
commit 2387a50c2b
2 changed files with 13 additions and 11 deletions

View File

@ -26,8 +26,10 @@ import copy
import pooler
import base64
import cStringIO
import re
from reportlab.lib.utils import ImageReader
_regex = re.compile('\[\[(.+?)\]\]')
class html2html(object):
def __init__(self, html, localcontext):
@ -49,16 +51,17 @@ class html2html(object):
process_text(child, new_child)
else:
if new_child.tag=='img' and new_child.get('name'):
src = utils._process_text(self, new_child.get('name'))
if src :
new_child.set('src','data:image/gif;base64,%s'%src)
output = cStringIO.StringIO(base64.decodestring(src))
img = ImageReader(output)
(width,height) = img.getSize()
new_child.set('width',str(width))
new_child.set('height',str(height))
else :
new_child.getparent().remove(new_child)
if _regex.findall(new_child.get('name')) :
src = utils._process_text(self, new_child.get('name'))
if src :
new_child.set('src','data:image/gif;base64,%s'%src)
output = cStringIO.StringIO(base64.decodestring(src))
img = ImageReader(output)
(width,height) = img.getSize()
new_child.set('width',str(width))
new_child.set('height',str(height))
else :
new_child.getparent().remove(new_child)
new_child.text = utils._process_text(self, child.text)
self._node = copy.deepcopy(self.etree)
for n in self._node:

View File

@ -610,7 +610,6 @@ class _rml_flowable(object):
if self.localcontext:
newtext = utils._process_text(self, node.text or '')
node.text = newtext
if not node.text: return False
image_data = base64.decodestring(node.text)
image = cStringIO.StringIO(image_data)
return platypus.Image(image, mask=(250,255,250,255,250,255), **(utils.attr_get(node, ['width','height'])))