summaryrefslogtreecommitdiff
path: root/bin/report/render/html2html/html2html.py
diff options
context:
space:
mode:
authorNaresh Choksy <nch@tinyerp.com>2009-06-10 09:51:45 +0530
committerNaresh Choksy <nch@tinyerp.com>2009-06-10 09:51:45 +0530
commitd63b2f24c93b758b320578877f38a5ad83cf21ee (patch)
tree62e343a0a51d28fc3f1aa51428229108af2442bd /bin/report/render/html2html/html2html.py
parent7561d80d6b5f410994600ce770d3ee3fbb960d00 (diff)
parentdb8f650de377a71bdc97a7b0f8ce420f8c30cce8 (diff)
merge
bzr revid: nch@tinyerp.com-20090609110258-9db6rlncos1okb57 bzr revid: nch@tinyerp.com-20090610042145-e6amffs8leyqi2e2
Diffstat (limited to 'bin/report/render/html2html/html2html.py')
-rw-r--r--bin/report/render/html2html/html2html.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/bin/report/render/html2html/html2html.py b/bin/report/render/html2html/html2html.py
index 28c22f4b10e..2cf5b147dd0 100644
--- a/bin/report/render/html2html/html2html.py
+++ b/bin/report/render/html2html/html2html.py
@@ -24,7 +24,12 @@ from report.render.rml2pdf import utils
from lxml import etree
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):
@@ -42,15 +47,24 @@ class html2html(object):
new_node.append(new_child)
if len(child):
for n in new_child:
+ new_child.text = utils._process_text(self, child.text)
new_child.remove(n)
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)
- 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()
+ if not new_child.get('width'):
+ new_child.set('width',str(width))
+ if not new_child.get('height') :
+ 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: