XSL-FO writes text above the line or fo: leader

I am creating a pdf from xml and xsl-fo and Apache FOP and I need to write text line by line. I mean something like a manual compilation form where you write first name, last name, etc. Something like this: Name: ______John_________


but with a line also under the name. I tried to use fo: leader. Everything is in a table cell. With this code

 <fo:table-cell column-number="3" font-size="10pt" number-columns-spanned="4">
   <fo:block space-before="2mm" wrap-option="no-wrap" overflow="visible" margin-top="2mm" margin-left="3mm">
     <xsl:value-of select="$element/value"/>
   </fo:block>
   <fo:block wrap-option="no-wrap" overflow="visible" margin-left="2mm" margin-top="0mm">
     <fo:leader leader-length="130mm"
                leader-pattern="rule"
                rule-style="solid"
                rule-thickness="0.1mm"
                color="black"></fo:leader>
   </fo:block>
 </fo:table-cell>

      

I get the line, but not immediately below the word, and if I set margin-top = "- 3mm" for the leader block, nothing changes. How can I get a result like this? Are there other ways?

Many thanks

+3


source to share


2 answers


I got the result in a different way: fo:block border-bottom="solid" border-bottom-width="0.2mm"

did the trick. <fo:leader />

c is </fo:block>

needed to emphasize the meaning (in this example from John) is empty.

<fo:table-row>
    <fo:table-cell font-size="10pt">
        <fo:block>
            <xsl:text>Nome:</xsl:text>
        </fo:block>
    </fo:table-cell>
    <fo:table-cell font-size="10pt">
        <fo:block border-bottom="solid" border-bottom-width="0.2mm">
            <xsl:text>John</xsl:text>
            <fo:leader />
        </fo:block>
    </fo:table-cell>
</fo:table-row>

      



enter image description here

+4


source


It's kind of a hack, but you can use fo:list-block

...

XSL-FO

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="my-page" page-width="8.5in" page-height="11in">
            <fo:region-body margin="1in" margin-top="1.5in" margin-bottom="1.5in"/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="my-page">
        <fo:flow flow-name="xsl-region-body">
            <fo:table width="50%">
                <fo:table-body>
                    <fo:table-row>
                        <fo:table-cell border-style="solid" padding="4px">
                            <fo:list-block provisional-distance-between-starts="15%">
                                <fo:list-item>
                                    <fo:list-item-label end-indent="label-end()">
                                        <fo:block>Name:</fo:block>
                                    </fo:list-item-label>
                                    <fo:list-item-body start-indent="body-start()">
                                        <fo:block text-align="center" border-bottom-style="solid">John</fo:block>
                                    </fo:list-item-body>
                                </fo:list-item>
                            </fo:list-block>
                        </fo:table-cell>
                    </fo:table-row>
                </fo:table-body>
            </fo:table>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

      



PDF output (used by FOP 1.0)

enter image description here

You will probably need to play around with provisional-distance-between-starts

it to find out what will work for your data.

+2


source







All Articles