[reportlab-users] Multiple fonts per line using Fraglines, Paragraph example?

hari jayaram harijay at gmail.com
Sat Apr 9 03:42:33 EDT 2011


Looking at the source code for ParaFrag(ABag) class and from the
reportlab documentation and a print of my Paragraph data structure , I
gathered that there are two ways to achieve multiple formats per
Paragraph line using reportlab platypus.

Elegant way :
Paragraph(text="<font name=Courier-Bold color=red size=12>A First set
of words</font><font name=Helvetica-Bold size=8>Smaller this
time</font>", style=mynewstyle))

Here the "mynewstyle" is ignored and the formatting is governed by
the xml attributes in the text block.


Another way that I gathered from looking at the print of a Paragraph
object also works:
Sloppy way:

Paragraph(text="garbage in test text not rendered",style =
mynewstyle,frags=[ParaFrag(bold=0, fontName='Courier-Bold',
fontSize=12, greek=0, italic=0, link=None, rise=0, strike=0, sub=0,
super=0, \
text='Another set of words', textColor=Color(1,0,0,1),
underline=0), ParaFrag(bold=0, fontName='Helvetica-Bold', fontSize=5,
greek=0, italic=0, link=None, rise=0, strike=0, \
sub=0, super=0, text='Still Smaller this time',
textColor=Color(0,0,0,1), underline=0)]))


I think I am starting to understand how platypus, ABag , Paragraph and
ParaFrag work.

Thanks

Hari

On Thu, Apr 7, 2011 at 9:43 PM, hari jayaram <harijay at gmail.com> wrote:

> Hi I want to render a line with multiple fonts onto a pdf file using

> the platypus library reportlab.platypus.paragraph.FragLine

> I my generated document I will have a series of  lines where I have

> two values separated by a semicolon (example text below). I

>  want the part before and after the ":" to be in different fonts.

>

>

> User Name in one  LARGE FONTt:

> /a/very/long/user/settings/directory/path/that/needs/a/different/font/setting

>

> I am quite the newbie to creating styles but I am hoping someone can

> tell me how to go about this using Fraglines and Paragraph.

> Can someone point me to a good example.

>

> Thanks

>

> Hari

>



More information about the reportlab-users mailing list