[reportlab-users] Values in Page Header

CLIFFORD ILKAY reportlab-users@reportlab.com
Sat, 14 Aug 2004 12:38:29 -0400


>On August 12, 2004 02:03 pm, CLIFFORD ILKAY wrote:
> > Imagine a grouped report, say a sales report by country. At the top of each
> > page, I want to have a title 'Sales for: %s' % theCountry. I am using a
> > SimpleDocTemplate with myFirstPage and myLaterPages and building up the doc
> > by iterating through the results of a db query. How do I inject the value
> > of theCountry in the page header for every page?

At 02:25 PM 12/08/2004 -0400, Derik Barclay wrote:
>I am not sure it can be done unless you know ahead of time where the page
>breaks are.
>If you knew you could create a list of page titles and move through the list
>in the beforePage...

I have something like this in mind:

select country, count(*) from countries group by country;
getResults into list

for each list element:
         getSalesFigures(country)
         for each sales figure:
                 add to PDF

This would create one big PDF of sales by country and because country would 
be known be known in advance of getting sales figures, the country could be 
injected on the header of each page. This is not as efficient from a SQL 
perspective but it makes this possible.

Another problem arises though. Many of the fancy printers/networked copiers 
can collate and staple so if the users wanted the report for each country 
to be collated and stapled, that would not be possible with one big report 
since it would be seen as one big print job. (I wonder if there is a way to 
send printer control codes in PDFs?) I suppose I could create individual 
PDFs by country but then I would not be able to display them all of them on 
the screen at once. If there were 150 reports, manually opening 150 files 
would become very tedious and opening all of them at once probably is not a 
good idea either. Perhaps I could generate one big file for display 
purposes and 150 individual files for printing. I could have the server zip 
the 150 files and email it to the user. Does this sound feasible or is 
there a better way? I doubt this is a unique need.

Regards,

Clifford Ilkay
Dinamis Corporation
3266 Yonge Street, Suite 1419
Toronto, Ontario
Canada M4N 3P6

Tel: 416-410-3326