I'm using XSL-FO with Apache FOP to take a sexy looking XML file and output it as a PDF, however I'm having a really basic problem trying to get a particular bit of information (the address) to be positioned from the right of the page, I can force it over to the right by increasing the left
attribute, but if I change my page size, orientation or margins this will immediately be useless.
Below is the code for the XSL, note the comment on line 23.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org开发者_运维技巧/1999/XSL/Format" version="1.0">
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="all-pages"
page-height="297mm"
page-width="210mm"
margin-top="1cm"
margin-bottom="1cm"
margin-left="1cm"
margin-right="1cm" >
<fo:region-body margin-top="5cm" margin-bottom="1.1cm"/>
<fo:region-before extent="1cm"/>
<fo:region-after extent="5mm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="default-sequence">
<fo:repeatable-page-master-reference master-reference="all-pages"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="default-sequence">
<fo:static-content flow-name="xsl-region-before" font-size="10pt" font-family="Helvetica" >
<!-- HERE'S MY PROBLEM, THE RIGHT ATTRIBUTE ISN'T BEHAVING ITSELF -->
<fo:block-container absolute-position="absolute" right="4cm" top="1cm" width="6cm" border-style="solid" border-width="1mm" >
<fo:list-block >
<fo:list-item>
<fo:list-item-label>
<fo:block></fo:block>
</fo:list-item-label>
<fo:list-item-body>
<fo:block>ABC</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label>
<fo:block></fo:block>
</fo:list-item-label>
<fo:list-item-body>
<fo:block>123</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:block-container>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after" padding-top="2pt" border-top-style="solid" border-top-width="1pt" border-top-color="rgb(192,192,192)" font-size="10pt" font-family="Helvetica">
<fo:block></fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" font-size="10pt" font-family="Helvetica">
<fo:block></fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
And as you can see by this screenshot the element isn't positioning correctly:
Any one know know why this is happening?
Bugger, looked at the FOP changelog and the two years between versions 0.95 and 1.0 made me think whether it was a bug, downloaded the new binaries and it's now positioning my element from the right.
精彩评论