[reportlab-users] Center align emoji's png images inside Paragraph

273 views
Skip to first unread message

Kaviraj Kanagaraj

unread,
Jul 14, 2015, 5:54:20 AM7/14/15
to reportl...@reportlab.com
Hi 

I am trying to insert emjo's png inside Paragraph in reportlab. Basically image size Im using 18x18 with Paragraph Font size of 18 with center alignment. If Paragraph contains less than 6 pngs, All emojis are center aligned. But once its more than that Its no more center aligned.

How to add those pngs inside paragraph without disturbing the paragraph styles?

Thanks in advance

Robin Becker

unread,
Jul 14, 2015, 7:29:38 AM7/14/15
to reportlab-users
.......
Can you please supply a simple example of the problem? I guess you are using an
18pt font and the img tag inside it, but I am not going to guess how this is
going wrong. I can make 18 x 18 images fairly easily, but exactly what the
layout is probably affects the problem. We have been asked before about emoji's
and I believe some fonts do have them, but using images would certaily be an
alternative.

I assume you mean vertically centred.
--
Robin Becker
_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
https://pairlist2.pair.net/mailman/listinfo/reportlab-users

Robin Becker

unread,
Jul 14, 2015, 8:36:29 AM7/14/15
to reportlab-users
On 14/07/2015 10:54, Kaviraj Kanagaraj wrote:
I tried the attached example in latest reportlab it seems to put the image in
the right place, but perhaps you can modify to show the problem you are having.
--
Robin Becker


>
> Thanks in advance
...

img-example.zip

Robin Becker

unread,
Jul 15, 2015, 11:36:31 AM7/15/15
to USERS REPORTLAB, Kaviraj Kanagaraj
On 15/07/2015 14:12, Kaviraj Kanagaraj wrote:
> Hi Robin,
>
> Thanks a lot for time. I have checked out your code. Here I attach the
> customized code about my exact scenario. I have attached the output pdf
> also. I have included both the "working paragraph" and "problematic
> paragraph" examples.
>
> Help me figuring out what is wrong. Thanks a lot again
>
> P.S: I dont know how to replay to your mail in reportlab group itself.
>
your email seemed to reach the reportl...@reprotlab.com group fine.

I'm not sure exactly what the problem is. There are 4 pages with centred
paragraphs drawn on them. Which is problematic and why?

I can only imagine that the last page which shows the text + images not centred
horizontally is the problem. I think that's because the last 'word' which
consists of nothing, but images is getting wrapped and the remnant first line
doesn't get centred properly. If that is your problem then I think this is a bug
in the break lines code. It seems we are assuming each img is a word and must be
followed by a space.

I'll see if there's an obvious fix.

Kaviraj Kanagaraj

unread,
Jul 15, 2015, 11:50:26 AM7/15/15
to Robin Becker, USERS REPORTLAB
Yea you are right thats the problem. But If you look closely except the first page none of them are center aligned correctly. Paragraph seems to be moving left as you increase the number of images. The problem may not only be in break lines code may also be in the way reportlab interpreting images. I mean even a single line paragraph is not properly center aligned if it contains images.. 

Thanks for looking into my problem.

Robin Becker

unread,
Jul 15, 2015, 12:53:06 PM7/15/15
to Kaviraj Kanagaraj, USERS REPORTLAB
On 15/07/2015 16:50, Kaviraj Kanagaraj wrote:
> Yea you are right thats the problem. But If you look closely except the
> first page none of them are center aligned correctly. Paragraph seems to be
> moving left as you increase the number of images. The problem may not only
> be in break lines code may also be in the way reportlab interpreting
> images. I mean even a single line paragraph is not properly center aligned
> if it contains images..

OK the bug is that each image is being regarded as a word and our code assumes
that words are followed by spaces so the wrong width gets computed. I'm looking
into it.
Reply all
Reply to author
Forward
0 new messages