1

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).

Hobbes
  • 1,964
  • 3
  • 18
  • 35
  • Please look at this answer - https://stackoverflow.com/a/225691/4824495 – Nadezhda Serafimova May 21 '18 at 10:24
  • I've looked at those attributes, but there is no way to specify e.g. page-break-inside="allow" or keep-together="no". IOW you can specify that content cannot have a page break, but you can't say "page breaks are allowed in this content". – Hobbes May 21 '18 at 10:54
  • `fo:external-graphic` is an inline-level FO. It shouldn't be a child of `fo:inline-container`. See https://www.w3.org/TR/xsl11/#d0e6532. – Tony Graham May 23 '18 at 08:39

1 Answers1

1

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>
Tony Graham
  • 7,306
  • 13
  • 20
  • It works for me. Still works for me when I remove the white-space between each `` and the following ``. – Tony Graham May 23 '18 at 08:46
  • Result! It didn't work because I applied the widows/orphans setting in the wrong place. When I add an fo:block that contains all the inline-containers, it works. – Hobbes May 24 '18 at 08:21