[reportlab-users] Multi-page formatting in Platypus
Peter Mattingly
pmattingly at mail.csuchico.edu
Fri Oct 17 22:22:53 EDT 2008
>
> tests/test_platypus_*.py
>
I'm using version 2.1 (the one available in the Ubuntu repositories), I have
no directory named "tests" in my reportlab directories:
/usr/share/doc/python-reportlab-doc
/usr/share/doc/python-reportlab
/usr/share/pyshared/reportlab
There aren't any directories named "tests" on my system, related to
reportlab. Any other places I should be looking? Should I be grabbing the
"tests" from the SVN?
tools/docco/rltemplate.py which is the template used for the manual.
This I was able to find, where you said it would be. I'm at a loss where to
look in this file, there's no comment labeled "Using a call back for the
header here" or anything like that. No class definitions, no function
definitions, etc. I did - however - see "Heading1" and "Heading2":
if style == 'Title':
> self.title = flowable.getPlainText()
> elif style == 'Heading1':
> self.chapter = flowable.getPlainText()
> key = 'ch%d' % self.chapterNo
> self.canv.bookmarkPage(key)
> self.canv.addOutlineEntry(flowable.getPlainText(),
> key, 0, 0)
> self.chapterNo = self.chapterNo + 1
> self.sectionNo = 1
> elif style == 'Heading2':
> self.section = flowable.text
> key = 'ch%ds%d' % (self.chapterNo, self.sectionNo)
> self.canv.bookmarkPage(key)
> self.canv.addOutlineEntry(flowable.getPlainText(),
> key, 1, 0)
> self.sectionNo = self.sectionNo + 1
It doesn't look like this is what you're talking about.
Then I looked for things that take PageTemplate's, which there were several:
class FrontCoverTemplate(PageTemplate):
> def __init__(self, id, pageSize=defaultPageSize):
> self.pageWidth = pageSize[0]
> self.pageHeight = pageSize[1]
> frame1 = Frame(inch,
> 3*inch,
> self.pageWidth - 2*inch,
> self.pageHeight - 518, id='cover')
> PageTemplate.__init__(self, id, [frame1]) # note lack of onPage
>
> def afterDrawPage(self, canvas, doc):
> canvas.saveState()
> canvas.drawImage('../images/replogo.gif',2*inch, 8*inch)
>
>
> canvas.setFont('Times-Roman', 10)
> canvas.line(inch, 120, self.pageWidth - inch, 120)
>
> canvas.drawString(inch, 100, '165 The Broadway')
> canvas.drawString(inch, 88, 'Wimbledon')
> canvas.drawString(inch, 76, 'London SW19 1NE')
> canvas.drawString(inch, 64, 'United Kingdom')
>
> canvas.restoreState()
This seemed to be the closes to what you were talking about. Though again
without some sort of pointer, comment or clue I don't see which of these
commands actually relates to which sections of the page.
Though I may be completely wrong.
This file seems awfully short for a template for the entire manual. Do I
have a the document you're thinking of?
On Mon, Oct 13, 2008 at 3:21 PM, Andy Robinson <andy at reportlab.com> wrote:
> 2008/10/13 Peter Mattingly <pmattingly at mail.csuchico.edu>:
>
> >
> > So: How do I define my frames across all of my pages?
>
> Headers like this don't go in frames. The frames are for the flowing
> content.
> They must be defined either as callback functions passed to the
> PageTemplate's constructor,
> which decorate the new page when it starts; or as subclasses of
> PageTemplate which do
> the same. Providing a generic "graphics callback" is far more
> flexible; it lets you do
> page borders, not just filling a box at the top or bottom like most
> word processors.
>
> Look at some of the tests in tests/test_platypus_*.py, or in
> tools/docco/rltemplate.py which is the template used for the manual.
>
> I admit the manual never explained this well; if someone can send in a
> contrib for this for the Platypus chapter, we'd be really grateful.
>
> - Andy
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20081017/135f35f4/attachment.htm>
More information about the reportlab-users
mailing list