Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dotted underline in XSL-FO

Tags:

xml

xslt

xsl-fo

I would like to have dotted underline words using XSL-FO.

I am able to underline the words using a template but not make the line dotted.

Here is the template that I am using:

<xsl:template match="db:link">
    <fo:inline font-family="AvenirNextLTPro-It" text-decoration="underline">
        <fo:basic-link internal-destination="{@idref}"> 
            <xsl:apply-templates/>
        </fo:basic-link>
    </fo:inline>            
</xsl:template>

And this is how I apply it on my words:

<link idref="policy">Policy</link>

Is there a parameter to make dotted underlines in XSL-FO?

like image 581
user17710829 Avatar asked Nov 30 '25 20:11

user17710829


2 Answers

The values supported for text-decoration do not include anything for dotted lines:

none | 
  [ [ underline | no-underline] || 
    [ overline | no-overline ] ||
    [ line-through | no-line-through ] || 
    [ blink | no-blink ] ] |
inherit

You may be able to get close to the desired affect via border-bottom-style:

<fo:inline font-family="AvenirNextLTPro-It" border-bottom-style="dotted">

Side note: Be sure to account for namespaces properly – your template is matching db:link yet the example you show is link. Depending on the default namespaces in play and the definition of the db namespace prefix, you may have a matching issue to address too.

like image 151
kjhughes Avatar answered Dec 02 '25 14:12

kjhughes


Like this:

    <fo:block>
       <fo:inline>I do not have anything. </fo:inline>
       <fo:inline border-bottom="0.5pt dotted black">Oh look! dotted underline! </fo:inline>
        <fo:inline>No extensions required.</fo:inline>
        <fo:inline border-bottom="0.5pt dotted black">And should work with any formatter! </fo:inline>
    </fo:block>

Resulting in:

enter image description here

Tested with FOP, RenderX and AHF without any extensions.

like image 42
Kevin Brown Avatar answered Dec 02 '25 14:12

Kevin Brown



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!