How to create a two-column layout with XSL-FO and FOP 1.0?

I have a piece of software that creates an XSL-FO description from a text file and converts it into a PDF document. Each line in the text file is converted to fo:block to FO, which sounds wrong, but I can’t change it right now. My document contains from 1 to 3 A4 pages.

Now I need to add graphics about 8 cm wide below the existing text. It should be aligned to the left. Next to him I want to place a block of text with a long description.

Layout example

I looked through several documents for FO and came up with the following:

 <fo:block intrusion-displace="block" margin-top="20mm"> <fo:float float="right"> <fo:block margin-left="20mm"> Bacon ipsum dolor sit amet laborum proident... </fo:block> </fo:float> <fo:external-graphic src="image.png"/> </fo:block> 

This seemed like what I wanted (after some tweaking, of course), but unfortunately FOP does not support fo:float ,

There is also a way to create multiple columns (without a table), but I was not able to figure out how this works. It seems like a new page is needed for this, but I need to use the current page if there is free space (which I don't need to care, I think).

So my question is: Is there any other way to build this without using fo:float ?

+6
source share
1 answer

You can try to use the image as a background image and leave a left pad that is as wide as the image.

 <fo:block intrusion-displace="block" margin-top="20mm"> <fo:block padding-left="20mm" background-image="image.png" background-repeat="no-repeat"> Bacon ipsum dolor sit amet laborum proident... </fo:block> </fo:block> 

If the image needs additional processing, which is possible only with <fo:external-graphic> , you can use the filling technique and an additional, absolutely positioned block container:

 <fo:block intrusion-displace="block" margin-top="20mm"> <fo:block padding-left="20mm"> Bacon ipsum dolor sit amet laborum proident... </fo:block> <fo:block-container absolute-position="absolute"> <fo:block> <fo:external-graphic src="image.png"/> </fo:block> </fo:block-container> </fo:block> 

The third option is to use a table.

+4
source

Source: https://habr.com/ru/post/921399/


All Articles