[reportlab-users] renderPM problem

John Pywtorak reportlab-users@reportlab.com
15 Mar 2004 09:38:13 -0800


Ok, The module you want is renderPDF not renderPM which can be imported
as:
from reportlab.graphics import renderPDF

Here is a complete working script which uses drawToFile, look at the
last line.  I think the script is fairly self explanatory.

#!/usr/bin/env python

import os
from time import strptime
import yaml
from reportlab.graphics.shapes import Drawing
from reportlab.graphics.charts.linecharts \
    import HorizontalLineChart, makeMarker
#from reportlab.graphics.charts.textlabels import Label
from reportlab.graphics import renderPDF


# XXX try, except
es = os.system("ssh changeme@changeme.calpoly.edu 'cat
/changeme/data.yaml' > data.yaml")
data = yaml.loadFile("data.yaml").next()

vert = [ ]
horiz = [ ]

for index in range(len(data)):
    real_minutes = int(data[index]['real'])

    if index != 0:
        p = int(data[index - 1]['real'])

        if p - 10 < real_minutes < p + 10:
            continue

    tt = strptime(data[index]['start'], "%Y/%m/%d %H:%M:%S")
    #print real_minutes, tt
    vert.append(real_minutes)
    horiz.append("%02d/%02d\n%02d:%02d" % tt[1:5])

lc = HorizontalLineChart()
lc.data = [ vert, ]
lc.x = 35
lc.y = 35
lc.height = 950
lc.width = 950
lc.joinedLines = 1
lc.categoryAxis.categoryNames = horiz
lc.categoryAxis.labels.boxAnchor = 'n'
lc.valueAxis.valueMin = 0
lc.valueAxis.valueMax = 120
lc.valueAxis.valueStep = 5
lc.lines[0].strokeWidth = 1
lc.lines.symbol = makeMarker('FilledDiamond')
lc.lineLabelFormat = "%2.0f"
drawing = Drawing(1000, 1000)
drawing.add(lc)
renderPDF.drawToFile(drawing, 'report.pdf', 'RAD11, 24x7, 199 Students')


John Pywtorak
Cal Poly

On Sun, 2004-03-14 at 07:03, ketul patel wrote:
> Hi
> I really need my renderPM problem solved.
> I really need to show some reports in my application & the deadline is fast 
> approaching.
> Both drawToFile,saveToFile methods are not present in the renderPM module.
> Somebody please help
> Thanks,
> Ketul