On Thursday 22 October 2009 15:12:13 John Martin wrote:
> Roberto Alsina <ralsina <at> netmanagers.com.ar> writes:
> > Honestly? I don't quite know right now.
> >
> > In any case, margin-left and margin-right are page attributes, not style
> > attributes, try leftIndent and rightIndent instead, but I am not sure if
> > they would work, either.
> >
> > I will take a look tonight and see what can be done, and if it can't,
> > I'll file an issue about it.
>
> I'm able to center a table using reportlab directly, but not when I go
> through rst2pdf. So I tried to track down what's different in these two
> cases. I didn't get very far in my comparison, but I thought I'd post my
> findings just in case they're useful.
>
> There's a difference in what happens when calling the drawOn method of
> class Flowable in platypus.flowables, which looks like this:
>
> def drawOn(self, canvas, x, y, _sW=0):
> "Tell it to draw itself on the canvas. Do not override"
> if _sW and hasattr(self,'hAlign'):
> from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT,
> TA_JUSTIFY
> a = self.hAlign
> if a in ('CENTER','CENTRE', TA_CENTER):
> x = x + 0.5*_sW
> ...
>
> When using reportlab directly:
> - drawOn has self.hAlign = 'CENTER' and _sW is a positive float
> - drawOn is called by method _add of platypus.frames.Frame, which uses
> flowable.wrap to set the variable w which contributes to _sW being
> nonzero.
>
> When going through rst2pdf:
> - drawOn has self.hAlign = 'CENTER' and _sW = 0.0. Having _sW = 0 looks
> like it prevents drawOn from moving the table to the right.
> - drawOn is called by method drawOn of class DelayedTable in
> rstpdf.flowables, which in turn is called by method draw in class
> BoundByWidth in rst2pdf.flowables. This routine computes aW to be the
> same as w, so it sets _sW = aW - w to zero.
>
> Again, all of this may be obvious to rst2pdf developers, but it's as far as
> I got.
>
> -John
Far from obvious, really :-)
Thanks for your effort, I am trying to free some time to check this.
--
("\''/").__..-''"`-. . Roberto Alsina
`9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH)
(_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar
_..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia
(l)-'' ((i).' ((!.' according to alexa.com (27/5/2007)

Roberto Alsina <ralsina <at> netmanagers.com.ar> writes:
>
> Honestly? I don't quite know right now.
>
> In any case, margin-left and margin-right are page attributes, not style
> attributes, try leftIndent and rightIndent instead, but I am not sure if they
> would work, either.
>
> I will take a look tonight and see what can be done, and if it can't, I'll
> file an issue about it.
>
I'm able to center a table using reportlab directly, but not when I go through
rst2pdf. So I tried to track down what's different in these two cases. I
didn't get very far in my comparison, but I thought I'd post my findings just
in case they're useful.
There's a difference in what happens when calling the drawOn method of class
Flowable in platypus.flowables, which looks like this:
def drawOn(self, canvas, x, y, _sW=0):
"Tell it to draw itself on the canvas. Do not override"
if _sW and hasattr(self,'hAlign'):
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT,
TA_JUSTIFY
a = self.hAlign
if a in ('CENTER','CENTRE', TA_CENTER):
x = x + 0.5*_sW
...
When using reportlab directly:
- drawOn has self.hAlign = 'CENTER' and _sW is a positive float
- drawOn is called by method _add of platypus.frames.Frame, which uses
flowable.wrap to set the variable w which contributes to _sW being nonzero.
When going through rst2pdf:
- drawOn has self.hAlign = 'CENTER' and _sW = 0.0. Having _sW = 0 looks like
it prevents drawOn from moving the table to the right.
- drawOn is called by method drawOn of class DelayedTable in rstpdf.flowables,
which in turn is called by method draw in class BoundByWidth in
rst2pdf.flowables. This routine computes aW to be the same as w, so it
sets _sW = aW - w to zero.
Again, all of this may be obvious to rst2pdf developers, but it's as far as I
got.
-John