[reportlab-users] Symbol < crashes platypus Paragraph text

george george at lecompte.org
Tue Apr 12 21:07:23 EDT 2005


Skipped content of type multipart/alternative-------------- next part --------------


import string

from math import pi, radians, sqrt,floor
from reportlab.pdfgen.canvas import Canvas     
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Frame
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.pagesizes import letter
from reportlab.lib.units import inch
from reportlab.lib import colors
from reportlab.graphics import renderPDF
from reportlab.graphics.shapes import *
from reportlab.lib.enums import TA_JUSTIFY
from reportlab.graphics.charts.lineplots import LinePlot
PAGE_HEIGHT=letter[1]; PAGE_WIDTH=letter[0]
styles = getSampleStyleSheet()
styleN = styles['Normal']
styleN.alignment = TA_JUSTIFY
styleH = styles['Heading1']
Title = "Tepee Constraints"
pageinfo = "Tepee Constraints"
def myFirstPage(canvas, doc):
    canvas.saveState()
    canvas.setFont('Times-Bold', 16)
    canvas.drawCenteredString(PAGE_WIDTH/2.0, PAHE_HEIGHT-1.5*inch, Title)
    canvas.setFont('Times-Roman',9)
    canvas.drawString(inch, 0.75 * inch, "First Page / %s" % pageinfo)
    canvas.restoreState()
def myLaterPages(canvas, doc):
    canvas.saveState()
    canvas.setFont('Times-Roman',9)
    canvas.drawString(inch, 0.75 * inch, "Page %d %s" %(doc.page, pageinfo))
    canvas.restoreState()
story = []
def H(stuff):
    story.append(Paragraph(stuff,styleH))
def P(stuff):
    story.append(Paragraph(stuff,styleN))
H("Problem Illustration")
P(""" I want to indicat that a is less than b however;  """)
try:
    P(""" a < b doesn't work""")
except:
    print"First try  doesn't work"
try:
    P(""" a \< b might work """)
except:
    print "the second try doesn't wrok either"

c = Canvas('Test.pdf')
f = Frame(inch,inch,6*inch, 9*inch, showBoundary=1)
f.addFromList(story,c)
c.save()

    


More information about the reportlab-users mailing list