Search code examples
xsl-fotext-alignletter-spacing

xsl-fo letter-spacing with text-align


Im using xsl-fo for printing pdfs (started to make my own library with itext, but xsl-fo looks fine for me). I have problem with aligning text which have different letter-spacing than default. my code is:

<fo:block border="solid 0.5mm green" text-align="center">
    <fo:inline border="solid 0.5mm black" letter-spacing="5pt">lorem ipsum</fo:inline>
</fo:block>

it produces the output:

Output

Problem is, that text "lorem ipsum" got to be positioned with larger letter-spacing, instead of positioning text with default letter-spacing and printing text with user defined letter-spacing. when we delete the letter-spacing="5pt" all works as expected.

Is there any override to this behavior? I have tried googling for some fancy attributes that will help, or tried playing with blocks but have no luck. Thanks.


Solution

  • Formatting the above FO with both RenderX and Apache FOP gives the results you desire if you use Helvetica font, centered with border surrounding the whole text. As you report, you are using Apache FOP with Arial ... this is your issue. I would report a bug to Apache FOP as their output is obviously wrong and should have nothing to do with the font selected.

    You could try to accomplish a similar layout with a table with three columns and proportional column width, but I would think it would yield the same incorrect result from Apache FOP..

    RenderX and FOP results for Helvetica

    Here is the result from oXygen and RenderX XEP using Arial font. It is correct. It is Apache FOP bug.

    RenderX XEP result using Arial