1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
24 from cStringIO import StringIO
25 import xml.dom.minidom
27 from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table
28 from reportlab.lib.units import mm
29 from reportlab.lib.pagesizes import A4
34 class simple(render.render):
36 self.result = StringIO()
37 parser = xml.dom.minidom.parseString(self.xml)
39 title = parser.documentElement.tagName
40 doc = SimpleDocTemplate(self.result, pagesize=A4, title=title,
41 author='OpenERP, Fabien Pinckaers', leftmargin=10*mm, rightmargin=10*mm)
43 styles = reportlab.lib.styles.getSampleStyleSheet()
44 title_style = copy.deepcopy(styles["Heading1"])
45 title_style.alignment = reportlab.lib.enums.TA_CENTER
46 story = [ Paragraph(title, title_style) ]
48 nodes = [ (parser.documentElement,0) ]
52 n=len(node[0].childNodes)-1
54 if node[0].childNodes[n].nodeType==3:
55 value += node[0].childNodes[n].nodeValue
57 nodes.insert( 0, (node[0].childNodes[n], node[1]+1) )
59 if not node[1] in style_level:
60 style = copy.deepcopy(styles["Normal"])
61 style.leftIndent=node[1]*6*mm
62 style.firstLineIndent=-3*mm
63 style_level[node[1]] = style
64 story.append( Paragraph('<b>%s</b>: %s' % (node[0].tagName, value), style_level[node[1]]))
66 return self.result.getvalue()
68 if __name__=='__main__':
74 <name>Fabien Pinckaers</name>
78 <name>Michel Pinckaers</name>
87 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: