[reportlab-users] Page n of m?
Harald Armin Massa
haraldarminmassa at gmail.com
Mon Aug 18 07:34:42 EDT 2008
Paul,
> Thanks for the help. I'd never have worked that out for myself.
you are welcome
> One other question: is it possible to retrieve and store the cursor
> position of the page number, so that when I do the drawString() later,
I am not aware of any method to do this. And with the described method
it will also be impossible, as the FORM gets drawn ONLY once per
document, and somehwo PDF defines "show it everywhere". i.E.: there
are no different "of N" for different pages, there is only ON <total
number of pages> within your document.
But more important: I recommend strongly not to do this.
"jumping pages numbers" are a major frustration for anybody reading
the document. Page numbers are usually used for reference, and it is
really bad if they are "somewhere" on the page. It is "verboten" to do
this. :)
Harald
> have the exact coordinates and don't need to recompute them? My problem is
> the position of the page number isn't fixed, it depends on what is above it
> in the frame.
>
> Regards
>
> P
>
>
>> Yes, it is possible.
>>
>> Usually the solution is:
>>
>> 1) add "Page <actual Page> of" to the footer of your Page
>> canv.drawRightString(10*cm, 0.75*cm, u"Page %s of % (doc.page,))
>>
>> 2) add a PDF-Form to the place right of the "of"
>> canv.doForm("pageCount")
>>
>> 3) render the PDF
>> 4) after the rendering, fill the Number of Pages into PDF-Form which
>> gets drawn after the "of"
>> def _endBuild(self):
>> self.canv.beginForm("pageCount")
>> self.canv.setFont(fontnormal,7)
>> self.canv.drawString(12*cm,0.75*cm u"%s" % (self.canv.
>> getPageNumber(),))
>> self.canv.endForm()
>> BaseDocTemplate._endBuild(self)
>
>
>
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607
no fx, no carrier pigeon
-
EuroPython 2009 will take place in Birmingham - Stay tuned!
More information about the reportlab-users
mailing list