Xsl-fo header - image on the left, three lines of text on the right, vertical alignment

Using apache FOP, you want to create a header with the logo aligned on the left, a three-line address aligned to the right, aligned to the top.

After doing the work ok, if it is executed inside the stream, but in the header of the static content ("xsl-region-before"), it gets the correct value on the left and on the right, but aligns the logo under the address block, as if the table definition were completely ignored.

I tried other options, for example, trying to embed these two or use float with similar results. The header simply treats them as separate blocks and stacks them. Anyone have any suggestions?

I found this other problem by asking the same question about footers, alas, there are no answers: I need an instance-alien object and text to align at the bottom of XSL-FO

Below is the corresponding snippet:

    <fo:layout-master-set>
        <fo:simple-page-master page-height="8.5in" page-width="11in" master-name="only" margin=".5in .5in .5in .5in">
            <fo:region-body region-name="xsl-region-body" margin-top="1in" margin-bottom=".5in"/>
            <fo:region-before region-name="xsl-region-before"/>
            <fo:region-after region-name="xsl-region-after"/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="only">
        <fo:static-content flow-name="xsl-region-before">
                <fo:block font-size="7pt">
                    <fo:table width="10in">
                        <fo:table-column/>
                        <fo:table-column/>
                        <fo:table-body>
                            <fo:table-row>
                                <fo:table-cell>
                                    <fo:block>
                                        <fo:external-graphic src="img/print_logo.png" content-width="2in"/>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell display-align="center">
                                    <fo:block text-align="right">
                                        123 Credibility Street
                                    </fo:block>
                                    <fo:block text-align="right">
                                        Chicago, IL  60606
                                    </fo:block>
                                    <fo:block text-align="right">
                                        312-123-4567
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </fo:table-body>
                    </fo:table>
                </fo:block>
        </fo:static-content>
+3
source share
2 answers

I managed to achieve the desired effect by putting two elements in two separate container blocks with absolute positioning:

<fo:static-content flow-name="xsl-region-before">
    <fo:block-container position="absolute">
        <fo:block>
            <fo:external-graphic src="img/print_logo.png" content-width="2in"/>
        </fo:block>
    </fo:block-container>
    <fo:block-container position="absolute">
        <fo:block text-align="right">
            123 Credibility Street
        </fo:block>
        <fo:block text-align="right">
            Chicago, IL  60606
        </fo:block>
        <fo:block text-align="right">
            312-123-4567
        </fo:block>
    </fo:block-container>
</fo:static-content>
+4
source

Late to respond, but the request should be answered. So here it is:

Yes, absolute positioning is required here, but more important is the sequence of container blocks that you place.

Content with the last container will be on top of the others.

+1
source

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


All Articles