xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremias Maerki <...@jeremias-maerki.ch>
Subject Re: Image overflow in FOP
Date Wed, 05 Nov 2008 17:08:33 GMT
Comments inline...

On 05.11.2008 16:49:56 Sebastien wrote:
> 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:
> http://img444.imageshack.us/my.php?image=imageoverflowbj6.png
> 
> 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
> http://img241.imageshack.us/my.php?image=imageoverflowwidthaz5.png
>  - with smaller height (but still big enough to make the image bigger
> than the space left at the end of page)
> http://img504.imageshack.us/my.php?image=imageoverflowheightjs7.png
> 
> 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:block>
>  <fo:instream-foreign-object width="100%" content-width="scale-to-fit"
> content-height="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]
>  </svg:svg>
>  </fo:instream-foreign-object>
> </fo:block>

I think that looks fine.

> 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:
> http://xmlgraphics.apache.org/fop/knownissues.html#Layout+Engine
> (external-graphic don't shrink)

No, that's the inability of FOP to shrink the image vertically if
there's not enough room. That's not the same as the requirement you've
stated above.

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

IMO, the instream-foreign-object part is already correct (first
screenshot) but you've got the keeps wrong.

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

Nah, that's really FOP's job.

> 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):
> http://www.nabble.com/Image-overflow-td5982795.html
> http://www.nabble.com/0.94-AND-0.95b-Images-to17627201.html#a17629647
> 
> For those who can understand french, here is a more detailed
> description of my problem:
> http://forum.hardware.fr/hfr/Programmation/XML-XSL/debordement-image-generer-sujet_118855_1.htm

Here's what I would do: Enable the i-f-o behaviour as in your first
screenshot, then remove all keeps. That should avoid the overflow. Then
add keep-with-next or keep-together one step after the other. I'm pretty
sure that you've just overdone the keeps. Please note that
keep-*="always" doesn't allow FOP to break the content appart.

Looking at your layout you'd probably have a keep-with-next on the green
bar to keep the bar with the following image. But it (probably) makes no
sense to glue the green bars together.

HTH & good luck
Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message