> From: Volker Haas <[email protected]>
> Richard Ash wrote:
> > I have a probable bug, and a more general question about the possibilities
> > of
> customising the output of mwlib.rl
> > Bug: if I put
> > text_align = TA_LEFT
> >
> You need to import the file where TA_LEFT is defined before you can use it:
>
> from reportlab.lib.enums import TA_LEFT
> text_align = TA_LEFT
Thanks! now working fine.
> > The more general question is about the different section styles defined in
> pdfstyles.py. There are lots of blocks like if mode == 'license':
> > style.fontSize = 5
> > style.leading = 1
> > style.spaceBefore = 0
> >
> > Is there any way I can disagree and (e.g.) change the font size for license
> blocks because I want it bigger? It seems if I just over-ride it
> unconditionally, then I will affect all text, but where do I get an object to
> test against from, or is the customconfig.py mechanism not designed for this?
> >
> I must admit that currently you can't use the customconfig.py file to change
> font size of the license for example. One could argue that the pdfstyles file
> is
> poorly designed - but I am somewhat hesitant to change it.
>
> The only solution which seems "practical" to me is to directly edit the
> pdfstyles.py file. If you want to do this in a somewhat painless manner you
> should probably use git to check out the mwlib.rl repository. If you go this
> route you should familiarize yourself with git and python (a little bit at
> least
> - indentation matters for example)
For the moment I can live with the sizes, I will come back to this when I have
more time to look at it.
Working on this I also hit a bug in PIL 1.1.7 which causes any page with an
image on it to be rendered as plain text (and no images). mw-render.log
contains tracebacks like
2010-02-19T09:37:57 rlwriter.error >> Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/mwlib/rl/rlwriter.py", line 387, in art
icleRenderingOK
testdoc.build(elements)
[...]
File "/usr/lib/python2.6/site-packages/mwlib/ext/reportlab/pdfgen/canvas.py",
line 794, in drawImage
rawdata = image.getRGBData()
File "/usr/lib/python2.6/site-packages/mwlib/ext/reportlab/lib/utils.py", line
664, in getRGBData
self._dataA = ImageReader(im.split()[3])
File "/usr/lib/python2.6/site-packages/PIL/Image.py", line 1497, in split
if self.im.bands == 1:
AttributeError: 'NoneType' object has no attribute 'bands'
The problem is that PIL should load the image before trying to access the
number of bands, but doesn't. This is known upstream (there is a debian bug
against PIL), to work around it you just need to do the load() explicitly
before trying to access the number of bands.
diff -ur mwlib.ext-0.12.2.orig/upstream-src/src/reportlab/lib/utils.py
mwlib.ext-0.12.2/upstream-src/src/reportlab/lib/utils.py
--- mwlib.ext-0.12.2.orig/upstream-src/src/reportlab/lib/utils.py
2009-09-11 13:10:24.000000000 +0100
+++ mwlib.ext-0.12.2/upstream-src/src/reportlab/lib/utils.py 2010-02-19
09:56:32.000000000 +0000
@@ -661,6 +661,7 @@
im = self._image
mode = self.mode = im.mode
if mode=='RGBA':
+ im.load()
self._dataA = ImageReader(im.split()[3])
im = im.convert('RGB')
self.mode = 'RGB'
I don't know if it's worth trying to put this through to Reportlab, but it
might help anyone else who finds that images don't work with PIL 1.1.7.
Thanks,
Richard
--
You received this message because you are subscribed to the Google Groups
"mwlib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/mwlib?hl=en.