Skip to main content
Inspiring
May 22, 2010
Question

About adding InLineGraphics

  • May 22, 2010
  • 2 replies
  • 707 views

Hi,

Question. why after I insert an image, the text flow renders it as it'd have "spaces" before and after it?

The original code is just an image wrapped by <p> and </p>.

Any way to prevent this behavior without deleting the spaces manually?

Tks.

This topic has been closed for replies.

2 replies

oscar7878Author
Inspiring
May 23, 2010

I just noticed that the spaces may be caused by spans, added by the TLF.

If I add this code:

<p>
    <img height="104" width="306" source=www.example.com/image.jpg"/>
</p>

and then I do TextFlowUtil.export( textFlow );, I get this:

<p>
    <span fontLookup="embeddedCFF"></span>
    <img fontLookup="embeddedCFF" height="104" width="306" source="[object InlineGraphicElement]"/>
    <span fontLookup="embeddedCFF"></span>
</p>

How can I prevent this without deleting the span (spaces) manually?

May 24, 2010

Those spans are empty, so I'm not sure what you mean by spaces - is there additional horizontal space around the image or extra vertical space?

When I import your markup I get an empty span after the image, which I expect is a product of our model expecting paragraphs to have a span element. The span is empty, though - so it shouldn't affect anything that gets displayed. I am not getting an empty span preceding the image.

May 24, 2010

Rich Dermer pointed out to me that it's much more likely that you're getting the extra spans because of the whitespace in your XML. If your XML looks like this:

<p>

     <img.../>

</p>

Then even with whitespaceCollapse set to true we'll still insert a space before and after the img. If you want to make sure the img element is the only thing in the paragraph then you need to make your XML look like this:

<p><img.../></p>

oscar7878Author
Inspiring
May 22, 2010

This is happening when the string I'm importing has something like this:

<p><img source='http://www.example.com/image.jpg'  width='100' height='100' /></p>