Discussion:
[reportlab-users] Image inside paragraph not appearing
Stevens, Ian
2008-01-24 21:19:58 UTC
Permalink
I'm having trouble getting images to appear within a Paragraph when I use the <img/> tag:

1 from reportlab.lib.styles import ParagraphStyle
2 from reportlab.pdfgen.canvas import Canvas
3 from reportlab.platypus import Paragraph, Frame
4
5 c = Canvas('test.pdf')
6 f = Frame(100, 700, 400, 100, showBoundary=True)
7 f.addFromList([Paragraph('This is a test image: <img src="test.gif" height="5"/>. That was a test.', ParagraphStyle(None))], c)
8 c.save()

Where test.gif is created with the following ImageMagick command:

echo this is a test | convert -background yellow -page 200x50 text:- test.gif

The image will not display. What am I missing?

thanks,
Ian.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20080124/466d476c/attachment.html>
Stevens, Ian
2008-01-25 20:02:52 UTC
Permalink
Is this code working for anyone? I've tried this on a few different
machines with the same results.

thanks,
Ian.


________________________________

From: reportlab-users-bounces at reportlab.com
[mailto:reportlab-users-bounces at reportlab.com] On Behalf Of Stevens, Ian
Sent: Thursday, January 24, 2008 4:20 PM
To: reportlab-users at reportlab.com
Subject: [reportlab-users] Image inside paragraph not appearing



I'm having trouble getting images to appear within a Paragraph
when I use the <img/> tag:

1 from reportlab.lib.styles import ParagraphStyle
2 from reportlab.pdfgen.canvas import Canvas
3 from reportlab.platypus import Paragraph, Frame
4
5 c = Canvas('test.pdf')
6 f = Frame(100, 700, 400, 100, showBoundary=True)
7 f.addFromList([Paragraph('This is a test image: <img
src="test.gif" height="5"/>. That was a test.', ParagraphStyle(None))],
c)
8 c.save()

Where test.gif is created with the following ImageMagick
command:

echo this is a test | convert -background yellow -page
200x50 text:- test.gif

The image will not display. What am I missing?

thanks,
Ian.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20080125/0252bfdc/attachment.html>
Robin Becker
2008-01-26 09:33:23 UTC
Permalink
Post by Stevens, Ian
Is this code working for anyone? I've tried this on a few different
machines with the same results.
thanks,
Ian.
.......
the img tag was added recently, but we have a test in the
reportlab/tests area called test_platypus_paragraphs.py; if that test is
run then the result file called test_platypus_paragraphs_autoleading.pdf
contains paragraphs with embedded images.
Post by Stevens, Ian
________________________________
From: reportlab-users-bounces at reportlab.com
[mailto:reportlab-users-bounces at reportlab.com] On Behalf Of Stevens, Ian
Sent: Thursday, January 24, 2008 4:20 PM
To: reportlab-users at reportlab.com
Subject: [reportlab-users] Image inside paragraph not appearing
I'm having trouble getting images to appear within a Paragraph
1 from reportlab.lib.styles import ParagraphStyle
2 from reportlab.pdfgen.canvas import Canvas
3 from reportlab.platypus import Paragraph, Frame
4
5 c = Canvas('test.pdf')
6 f = Frame(100, 700, 400, 100, showBoundary=True)
7 f.addFromList([Paragraph('This is a test image: <img
src="test.gif" height="5"/>. That was a test.', ParagraphStyle(None))],
c)
8 c.save()
Where test.gif is created with the following ImageMagick
echo this is a test | convert -background yellow -page
200x50 text:- test.gif
The image will not display. What am I missing?
thanks,
Ian.
------------------------------------------------------------------------
_______________________________________________
reportlab-users mailing list
reportlab-users at reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users
--
Robin Becker
Stevens, Ian
2008-01-28 17:30:18 UTC
Permalink
Thanks, it's working now that I'm using trunk. Is there any way to
honour spacing to the right of the image? Padding is applied to the
left of the image, but not to the right even if there are spaces after
the image. This is evident in figure A-49 in the user guide as well.

Thanks,
Ian.
-----Original Message-----
From: reportlab-users-bounces at reportlab.com
[mailto:reportlab-users-bounces at reportlab.com] On Behalf Of
Robin Becker
Sent: Saturday, January 26, 2008 4:33 AM
To: Support list for users of Reportlab software
Subject: Re: [reportlab-users] Image inside paragraph not appearing
Post by Stevens, Ian
Is this code working for anyone? I've tried this on a few
different
Post by Stevens, Ian
machines with the same results.
thanks,
Ian.
.......
the img tag was added recently, but we have a test in the
reportlab/tests area called test_platypus_paragraphs.py; if
that test is run then the result file called
test_platypus_paragraphs_autoleading.pdf
contains paragraphs with embedded images.
Post by Stevens, Ian
________________________________
From: reportlab-users-bounces at reportlab.com
[mailto:reportlab-users-bounces at reportlab.com] On Behalf Of
Stevens, Ian
Post by Stevens, Ian
Sent: Thursday, January 24, 2008 4:20 PM
To: reportlab-users at reportlab.com
Subject: [reportlab-users] Image inside paragraph not appearing
I'm having trouble getting images to appear within a
Paragraph when I
Post by Stevens, Ian
1 from reportlab.lib.styles import ParagraphStyle
2 from reportlab.pdfgen.canvas import Canvas
3 from reportlab.platypus import Paragraph, Frame
4
5 c = Canvas('test.pdf')
6 f = Frame(100, 700, 400, 100, showBoundary=True)
7 f.addFromList([Paragraph('This is a test image: <img
src="test.gif" height="5"/>. That was a test.',
ParagraphStyle(None))],
c)
8 c.save()
Where test.gif is created with the following ImageMagick
echo this is a test | convert -background yellow
-page 200x50
Post by Stevens, Ian
text:- test.gif
The image will not display. What am I missing?
thanks,
Ian.
----------------------------------------------------------------------
Post by Stevens, Ian
--
_______________________________________________
reportlab-users mailing list
reportlab-users at reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users
--
Robin Becker
_______________________________________________
reportlab-users mailing list
reportlab-users at reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users
Robin Becker
2008-01-28 18:25:55 UTC
Permalink
Post by Stevens, Ian
Thanks, it's working now that I'm using trunk. Is there any way to
honour spacing to the right of the image? Padding is applied to the
left of the image, but not to the right even if there are spaces after
the image. This is evident in figure A-49 in the user guide as well.
Thanks,
Ian.
......
not sure exactly what's going on in the userguide, but the test shows spacing on
the right. The very last thing looks like this

Paragraph('''<img src="../docs/images/testimg.gif" valign="top"/> image is very
first thing in the line.''', style=normal)

and that certainly appears to show a space between the image and the text. This
was one of our bug cases during development. When I add the text from A-49 to
the case in test_platypus_paragraphs.py

Paragraph('''<para autoLeading="off" fontSize=12>This &lt;img/&gt; <img
src="../docs/images/testimg.gif" valign="top"/> is aligned <b>top</b>.<br/><br/>
This &lt;img/&gt; <img src="../docs/images/testimg.gif" valign="bottom"/> is
aligned <b>bottom</b>.<br/><br/> This &lt;img/&gt; <img
src="../docs/images/testimg.gif" valign="middle"/> is aligned <b>middle</b>.<br/><br/> This &lt;img/&gt; <img src="../docs/images/testimg.gif"
valign="-4"/> is aligned <b>-4</b>.<br/><br/> This &lt;img/&gt; <img
src="../docs/images/testimg.gif" valign="+4"/> is aligned <b>+4</b>.<br/><br/>
This &lt;img/&gt; <img src="../docs/images/testimg.gif" width="10"/> has width
<b>10</b>.<br/><br/> </para>''', style=normal)


I see the attached pdf which seems to be respecting the right space. I suspect
some kind of pre-processing is going on in the userguide creation I'll have to
check further.
--
Robin Becker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_platypus_paragraphs_autoleading.pdf
Type: application/pdf
Size: 5193 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20080128/2ce8a6b5/attachment.pdf>
Continue reading on narkive:
Loading...