from reportlab.platypus import Paragraph
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.units import mm
import dtutil
import datetime
st = ParagraphStyle( 'lettera' )
st.fontSize = 12
class lt_indir (Paragraph):
def __init__( self, txt ):
ntxt = '<para leftIndent=90mm >%s</para>' % txt
Paragraph.__init__( self, ntxt, st, None )
class lt_data (Paragraph):
def __init__( self, dt=None, luogo='Modena' ):
if dt == None: dt = datetime.date.today()
sdt = dtutil.timedelta_serializer( dt )
txt = luogo + ', ' + sdt
ntxt = '<para leftIndent=90mm spaceBefore=1cm spaceAfter=1cm>'
ntxt += txt + '</para>'
Paragraph.__init__( self, ntxt, st, None )
class lt_oggetto (Paragraph):
def __init__( self, txt ):
ntxt = '<para spaceBefore=1cm spaceAfter=1cm>Oggetto: '
ntxt += txt + ' </para>'
Paragraph.__init__( self, ntxt, st, None )
class lt_firma (Paragraph):
def __init__( self, txt ):
ntxt = '<para leftIndent=90mm spaceBefore=1cm>%s</para>' % txt
Paragraph.__init__( self, ntxt, st, None )
class lt_body (Paragraph):
def __init__( self, txt ):
ntxt = '<para firstLineIndent=10mm spaceBefore=1cm spaceAfter=1cm>'
ntxt += txt + '</para>'
Paragraph.__init__( self, ntxt, st, None )
def lettera( ):
lf = []
lf.append( lt_indir( ) )
lf.append( lt_data( ) )
lf.append( lt_oggetto( ) )
lf.append( lt_body( ) )
lf.append( lt_firma( ) )
return lf