Created
March 6, 2013 08:34
-
-
Save kylemacfarlane/5097662 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cProfile | |
from optparse import OptionParser | |
from z3c.rml import rml2pdf | |
parser = OptionParser() | |
parser.add_option('-c', '--cells', | |
action='store', dest='cells', default=0, | |
help='number of table cells (34 attributes)') | |
parser.add_option('-p', '--paras', | |
action='store', dest='paras', default=0, | |
help='number of paraStyles (29 attributes)') | |
parser.add_option('-b', '--barcodes', | |
action='store', dest='barcodes', default=0, | |
help='number of barcodeFlowables (27 attributes)') | |
parser.add_option('-s', '--sort', | |
action='store', dest='sort', default='cumulative', | |
help='profiler sort order') | |
head = """<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?> | |
<!DOCTYPE document SYSTEM "rml.dtd"> | |
<document filename="big_rml.pdf"> | |
<template pagesize="210mm,297mm" showBoundary="0"> | |
<pageTemplate id="main"> | |
<frame id="main" x1="0mm" y1="0mm" width="210mm" height="297mm" /> | |
</pageTemplate> | |
</template> | |
<stylesheet>""" | |
middle = """</stylesheet> | |
<story>""" | |
foot = """</story> | |
</document>""" | |
(options, args) = parser.parse_args() | |
cells, paras, barcodes = [], [], [] | |
for i in xrange(0, int(options.paras)): | |
paras.append('<paraStyle name="test%s" fontColor="red" />' % i) | |
if options.cells: | |
cells.append('<blockTable><tr>') | |
for i in xrange(0, int(options.cells)): | |
cells.append('<td>%s</td>' % i) | |
if not i % 10 and i < int(options.cells) - 1: | |
cells.append('</tr><tr>') | |
cells.append('</tr></blockTable>') | |
if options.barcodes: | |
for i in xrange(0, int(options.barcodes)): | |
barcodes.append('<barCodeFlowable code="Code128" value="%s" barWidth="0.1mm" quiet="yes" />' % i) | |
rml = '\n'.join([head] + paras + [middle] + cells + barcodes + [foot]) | |
def render(): | |
rml2pdf.parseString(rml) | |
cProfile.run('render()', sort=options.sort) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment