[xsl] Image overflow in FOP

Subject: [xsl] Image overflow in FOP
From: Sebastien <kamui.rouch@xxxxxxxxx>
Date: Wed, 5 Nov 2008 16:45:57 +0100
Hi !
I'm using FOP 0.95 to generate a PDF from an XML document.
I'm using XSL-FO to make the transformation and i'm having
difficulties with images, especially making them to fit within page or
to jump over the next one.
All these images are SVG (within instream-foreign-object). The SVG is
made of a large JPG background imported with <svg:image> and one or
several <svg:path> or other basic shapes.
The only constraint i want for the images is to fit the page width,
and conserve aspect ratio.
That i managed to achieve it. But the problem is that the image
overflow the page height whenever there isn't enough room left at the
end of the page. Here is a screenshot of what the problem is:

What i want to do is making FOP to do a page-break when the image
can't fit into the page.
I tried every combinations of keep constraints with no luck.
I even tried to fix (or remove) the width and the height on the
instream-foreign-object but FOP still doesn't want to jump to the next
page :'(
Here are some screenshots of the result:
 - without width
 - with smaller height (but still big enough to make the image bigger
than the space left at the end of page)

We can see that the image is very well scaled up/down but i can't make
FOP to break-page :'(

Here is the incriminated piece of code (corresponding to the first screenshot)
 <fo:instream-foreign-object width="100%" content-width="scale-to-fit"
  <svg:svg viewBox="519025 -6702573 5363 4051" height="2430px" width="3219px">
   <svg:image height="4051" width="5363" y="-6702573" x="519025"
xlink:href="file:///C:\bdd\docs\cartes\Scan25_Georef.jpg" />
    [some paths, rects and texts]

It seems like one of the FOP known issue in the LayoutEngine, but i'm
not quite sure because i use instream-foreign-object instead of
(external-graphic don't shrink)

My questions are:
 - is it possible to do what i want (having a page-break whenever it's
needed) with instream-foreign-object (and with FOP) ?
 - in case it's not, how could i calculate the space left at the end
of page to decide whether i put a break-before="page" on the
corresponding block or not ? I saw some xpath in FOP testcases which
tried to access some kind of "internal properties" like viewports
etc... and i wondered whether it's possible for me to use these path
to retrieve the remaining free space (and for my culture: are these
paths part of the standard or specific to FOP ?)

Thanks in advance for your help, i'm stuck with this issue for days...

Some ressources i found (and tried whenever it applied to my pb, but
with no luck):

For those who can understand french, here is a more detailed
description of my problem:

Current Thread