1
##############################################################################
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
31
from StringIO import StringIO
32
import xml.dom.minidom
34
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table
35
from reportlab.lib.units import mm
36
from reportlab.lib.pagesizes import A4
41
class simple(render.render):
43
self.result = StringIO()
44
parser = xml.dom.minidom.parseString(self.xml)
46
title = parser.documentElement.tagName
47
doc = SimpleDocTemplate(self.result, pagesize=A4, title=title,
48
author='Tiny ERP, Fabien Pinckaers', leftmargin=10*mm, rightmargin=10*mm)
50
styles = reportlab.lib.styles.getSampleStyleSheet()
51
title_style = copy.deepcopy(styles["Heading1"])
52
title_style.alignment = reportlab.lib.enums.TA_CENTER
53
story = [ Paragraph(title, title_style) ]
55
nodes = [ (parser.documentElement,0) ]
59
n=len(node[0].childNodes)-1
61
if node[0].childNodes[n].nodeType==3:
62
value += node[0].childNodes[n].nodeValue
64
nodes.insert( 0, (node[0].childNodes[n], node[1]+1) )
66
if not node[1] in style_level:
67
style = copy.deepcopy(styles["Normal"])
68
style.leftIndent=node[1]*6*mm
69
style.firstLineIndent=-3*mm
70
style_level[node[1]] = style
71
story.append( Paragraph('<b>%s</b>: %s' % (node[0].tagName, value), style_level[node[1]]))
73
return self.result.getvalue()
75
if __name__=='__main__':
80
<name>Fabien Pinckaers</name>
84
<name>Michel Pinckaers</name>