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