Multiple inline-containers in one block - can't get them to break to the next page

662 views Asked by At

I'm using inline-containers to render a series of images. My source file has 5 paragraphs, each containing 1 image.

<para stylename="Numbered Figure">
    <image file="P_1568.pdf" width="7.90cm" height="12cm"/>
</para>

I've got an A4 page, with room for 2 of these images side-by-side and 2 above each other.

My FO:

<xsl:when test="@stylename = 'Numbered Figure'">
    <fo:block widows="1" orphans="1">
      <fo:inline-container width="descendant::image/@width">
        <fo:external-graphic src="descendant::image/@file">
        <fo:block-container>
             code for placing a number in the top left corner of the image
        </fo:block-container> 
    </fo:inline-container>
  <fo:block>

This is the result: the inline-containers don't wrap to the next page, but overflow the page.
enter image description here

This looks like the 5 inline-containers are treated like one word, so I tried adding a space between each inline-container:

</fo:inline-container><fo:inline><xsl:text> </xsl:text></fo:inline>

That results in image 4 and 5 wrapping to the second page, instead of my intent of having image 1-4 on the first page. The space is too wide, image 3+4+space don't fit on one line.
I tried using a zero-width space (U+200B) instead, but then the images go back to overflowing on page 1 again.

What I've tried so far, all unsuccessful:

  • adding an fo:inline containing a whitespace character after each inline-container
  • specifying widows="1" orphans="1" on the containing fo:block

My goal is to have image 5 wrap to the second page. Is there an attribute I can set to allow a break between 2 inline-containers?

(I need the inline-container because I'm placing a text element on top of each image). Using Antennahouse Formatter.

Edit: This could be a problem in Antennahouse Formatter. When my source contains 7 images, the images are placed correctly (4 images on page 1, 3 images on page 2).

1

There are 1 answers

2
Tony Graham On BEST ANSWER

Set both widows and orphans to 1 so that the block can break and put just one line on the next page.

<fo:block widows="1" orphans="1">
    <fo:inline-container width="7.90cm" height="12cm">
        <fo:block><fo:external-graphic src="ah-logo.svg" /></fo:block>
    </fo:inline-container>
    <fo:inline-container width="7.90cm" height="12cm">
        <fo:block><fo:external-graphic src="ah-logo.svg" /></fo:block>
    </fo:inline-container>
    <fo:inline-container width="7.90cm" height="12cm">
        <fo:block><fo:external-graphic src="ah-logo.svg" /></fo:block>
    </fo:inline-container>
    <fo:inline-container width="7.90cm" height="12cm">
        <fo:block><fo:external-graphic src="ah-logo.svg" /></fo:block>
    </fo:inline-container>
    <fo:inline-container width="7.90cm" height="12cm">
        <fo:block><fo:external-graphic src="ah-logo.svg" /></fo:block>
    </fo:inline-container>
</fo:block>