I am trying to add a dotted line inside a table. I
Below is the XSLT . When I use the border-style = "dotted" the line appears as a solid line and not a dotted line.
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:m="http://www.ibm.com/maximo">
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="hello" page-height="11in" page-width="8.5in" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="hello">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:tab le width="100mm">
<fo:table-column/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block border-before-style="dashed" border-before-width="1mm" border-before-width.length="1pt">sdsdasd</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
Is the dotted style not supported in XSL-FO. I am using FONET.dll for .Net
FO.NET started as a port of Apache FOP 0.20.4 to the .NET environment.
That version of FOP did not support the whole FO standard, the different border styles being among the unsupported features.
Related
I am trying to addd multiple pages with this code. The content of each page works individiually. I looked for an example on how to add multiple pages but everyone I came has not worked for me. Am I making some general error here? It would be really helpful if some could add the basic structure I would need to use for to pages.
<?xml version="1.0" encoding="UTF-8" ?>
<fo:root
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
font-family="Freesans">
<fo:layout-master-set>
<fo:simple-page-master master-name="standard"
page-height="15.2cm"
page-width="8.1cm"
margin-top="1cm"
margin-bottom="1cm"
margin-left="1.5cm"
margin-right="1.5cm">
<fo:region-body margin-top="1cm"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="rest"
page-height="15.2cm"
page-width="8.1cm"
margin-top="1cm"
margin-bottom="1cm"
margin-left="1.5cm"
margin-right="1.5cm">
<fo:region-body margin-top="1cm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="standard">
<fo:repeatable-page-master-reference master-name="rest"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="standard" force-page-count="no-force">
<fo:flow flow-name="xsl-region-body" font-size="8pt">
<fo:block text-align="right" >
<fo:page-number/> / <fo:page-number-citation ref-id="totalPages"/>
</fo:block>
<!--content-->
<fo:block id="totalPages"></fo:block>
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="rest" force-page-count="no-force">
<fo:flow flow-name="xsl-region-body" font-size="8pt">
<fo:block text-align="right" >
<fo:page-number/> / <fo:page-number-citation ref-id="totalPages"/>
</fo:block>
<!--content-->
<fo:block id="totalPages"></fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
This is my following xslt code :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output encoding="iso-8859-1" />
<xsl:template match ="records">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="list">
<fo:region-body></fo:region-body>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="list">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:table>
<fo:table-body>
<xsl:for-each select="./list">
<fo:table-row>
<xsl:for-each select="./item">
<fo:table-cell border="solid 1px bold" text-align="center" backgr="green">
<fo:block><xsl:value-of select="val" /></fo:block>
</fo:table-cell>
</xsl:for-each>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
i am trying to add backgorund table-cell,but it is not working.
In foLtable-cell i have added backgr attribute, but it didnot worked.
The correct attribute for defining an background color is "background", but you used "backgr" instead. I tried the corrected code and it works as expected (using the Altsoft Xml2PDF Renderer).
It must be like
<fo:table-cell border="solid 1px bold" text-align="center"
background-color="green">
See also :XSL-FO table-cell Object
You can use the background-color attribute on a table-row or table-header element.
<fo:table-header background-color="#555">
or
<fo:table-row background-color="#555">
I am doing an xsl transform and I want to put several different documents in the same pdf. I have simple-page-masters for the first page, last page and other pages. I need to figure out a way to start a new document by using the last page and then the first page and reset the page numbers.
<fo:layout-master-set>
<fo:simple-page-master master-name="first-page">
<fo:region-body margin-bottom="1in" region-name="main-body"/>
<fo:region-after extent="1in" region-name="page-footer" display-align="after"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="other-pages">
<fo:region-body margin-top=".5in" margin-bottom=".5in" region-name="main-body"/>
<fo:region-before extent=".5in" region-name="page-header" display-align="before"/>
<fo:region-after extent=".5in" region-name="page-footer" display-align="after"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="last-page">
<fo:region-body margin-top=".5in" margin-bottom="1in" region-name="main-body"/>
<fo:region-before extent=".5in" region-name="page-header" display-align="before"/>
<fo:region-after extent="1in" region-name="page-footer" display-align="after"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="my-sequence">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first"
master-reference="first-page"/>
<fo:conditional-page-master-reference page-position="last"
master-reference="last-page"/>
<fo:conditional-page-master-reference odd-or-even="rest"
master-reference="other-pages"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
I tried setting the initial-page-number but it won't let me do it inside a page. Any ideas?
Here is the page-sequence.
<fo:page-sequence master-reference="my-sequence">
<fo:static-content flow-name="page-header" font-style="italic">
<xsl:if test="/Report[string-length(#print-page-headers) = 0 or #print-page-headers != 'false']">
<fo:block>
<fo:table width="100%" table-layout="fixed">
<fo:table-column/>
<fo:table-column/>
<fo:table-body>
<fo:table-row line-height="12pt" font-size="10pt">
<fo:table-cell>
<fo:block text-align="left">
<xsl:value-of select="/Report/ReportInfo/title "/>
</fo:block>
</fo:table-cell>
<fo:table-cell line-height="12pt" font-size="10pt">
<fo:block text-align="right">
Page <fo:page-number/> of <fo:page-number-citation ref-id="terminator"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
<fo:block>
<fo:leader leader-pattern="rule" rule-thickness="1pt" leader-length="100%"/>
</fo:block>
</xsl:if>
</fo:static-content>
<fo:static-content flow-name="page-footer">
<xsl:if test="/Report[string-length(#print-page-footers) = 0 or #print-page-footers != 'false']">
<fo:block >
<fo:table width="100%" table-layout="fixed">
<fo:table-column/>
<fo:table-body>
<fo:table-row height="9in">
<fo:table-cell display-align="after">
<fo:retrieve-marker retrieve-class-name="includes"/>
<fo:table width="100%" table-layout="fixed">
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-body>
<fo:table-row>
<fo:table-cell text-align="left">
<fo:block font-family="serif" font-size="8pt">
<xsl:value-of select="/Report/reportName"/>
</fo:block>
</fo:table-cell>
<fo:table-cell text-align="center">
<fo:block font-family="serif" font-size="6pt">
<xsl:text></xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell text-align="right">
<fo:block font-family="serif" font-size="8pt">
<xsl:value-of select="/Report/ReportInfo/date"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell number-columns-spanned="3" text-align="center">
<fo:block font-family="serif" font-size="6pt">
<xsl:text></xsl:text>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:if>
</fo:static-content>
<fo:flow flow-name="main-body">
<fo:block hyphenate="true" language="en">
<xsl:apply-templates/>
</fo:block>
<fo:block id="terminator"/>
</fo:flow>
</fo:page-sequence>
I tried using a template to reset the initial page number:
<xsl:template match="newreport">
<fo:page-sequence initial-page-number="1" master-reference="my-sequence">
<fo:static-content flow-name="page-header" font-style="italic">
<fo:block break-before="page"/>
<fo:block>
<fo:table width="100%" table-layout="fixed">
<fo:table-column/>
<fo:table-column/>
<fo:table-body>
<fo:table-row line-height="12pt" font-size="10pt">
<fo:table-cell>
<fo:block text-align="left">
<xsl:value-of select="/Report/ReportInfo/title "/>
</fo:block>
</fo:table-cell>
<fo:table-cell line-height="12pt" font-size="10pt">
<fo:block text-align="right">
Page <fo:page-number/> of <fo:page-number-citation ref-id="terminator"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
<fo:block>
<fo:leader leader-pattern="rule" rule-thickness="1pt" leader-length="100%"/>
</fo:block>
</fo:static-content>
</fo:page-sequence>
</xsl:template>
This doesn't work. I copied the code from the first page sequence. I want to be able to reset to the first page and do the page header, etc.
Perhaps you wish to adapt this sample to your, this works perfectly fine for Page X of Y references in a multiple batch document. One key here is that you must use a unique reference to document "chunk". You would use something unique in the XML, but I find it just as easy to use generate-id(.) on the repeating document, adding that id to the fo:flow and then using fo:page-number-citation-last with that id. Thus you get the last page of each of the flows.
Sample input:
<batch>
<document>
<page/>
<page/>
<page/>
<page/>
<page/>
</document>
<document>
<page/>
<page/>
<page/>
</document>
<document>
<page/>
<page/>
<page/>
</document>
</batch>
Sample XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="pages">
<fo:region-body margin-top="1in"/>
<fo:region-before extent="0.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<xsl:apply-templates/>
</fo:root>
</xsl:template>
<xsl:template match="document">
<fo:page-sequence master-reference="pages" initial-page-number="1" force-page-count="no-force">
<fo:static-content flow-name="xsl-region-before">
<fo:block>
Page <fo:page-number/> of <fo:page-number-citation-last ref-id="{generate-id(.)}"/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" id="{generate-id(.)}">
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</xsl:template>
<xsl:template match="page">
<fo:block break-before="page">
I am a page
</fo:block>
</xsl:template>
</xsl:stylesheet>
The output shows 1 of 5, 2 of 5, 3 of 5 ... followed by 1 of 3, 2 of 3 ... works perfect.
I'm using ApacheFOP to create a pdf which has multiple pages of content and a watermark (semi-transparent) on every page. I'm struggling quite a bit with XSLFO and got a proof of concept working using the list functionality - however I imagine there is a simpler way. Can someone more familiar with xslfo provide a simpler solution? Below is my code:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" indent="yes" />
<xsl:param name="watermarkPath" />
<xsl:param name="pdfPages" />
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page"
page-height="11in" page-width="8.5in" margin="0.5in">
<fo:region-body />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<xsl:for-each select="$pdfPages">
<fo:block-container>
<fo:list-block>
<fo:list-item>
<fo:list-item-label>
<fo:block>
<fo:external-graphic
content-width="7.5in">
<xsl:attribute name="src">
<xsl:value-of
select="concat('data:image/png;base64,',.)" />
</xsl:attribute>
</fo:external-graphic>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<fo:external-graphic
content-width="7.5in">
<xsl:attribute name="src">
<xsl:value-of select="$watermarkPath" />
</xsl:attribute>
</fo:external-graphic>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:block-container>
</xsl:for-each>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
Not sure it works with FOP but if it was a full size image of the page ...
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page"
page-height="11in" page-width="8.5in" margin="0.5in">
<fo:region-body />
<fo:region-before extent="11in" region-name="myheader" background-image="{path-to-my-image}"/>
</fo:simple-page-master>
</fo:layout-master-set>
If not, then put an absolute-positioned block-container inside the actual static-content for region "myheader" and don't use the background-image above.
<fo:page-sequence master-reference="my-page">
<fo:static-content flow-name="myheader">
<fo:block-container position="absolute" top="XX" left="XX">
<fo:block>
<fo:external-graphic .../>
</fo:block>
</fo:block-container>
</fo:static-content>
If you truly want an overlay (meaning over the top of all content) then put it in region-after and not before.
I put my background image in the region-body :
fo:region-body background-image="{$Url}"/
I am new to XSL-FO and have a very basic question, the following are xsl and xml files.
I expect "xxx" to be outputted for every xml node "inhouse" (template match).
But I am not getting it.
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="CustomerData">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simple" page-height="29.7cm" page-width="21.0cm" margin-left="1.5cm" margin-right="1.5cm" margin-top="0cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="0cm"/>
<fo:region-after extent="0cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simple">
<fo:flow flow-name="xsl-region-body">
<fo:block font-family="Arial" font-size="8.5pt" font-weight="normal">
abc
</fo:block>
<xsl:template match="inhouse">
<fo:block color="#053679">
xxx
</fo:block>
</xsl:template>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CustomerData>
<inhouse>
<customerList>
<customer>
<name>Tom</name>
</customer>
</customerList>
</inhouse>
</CustomerData>
The issue here is that you have a template match for inhouse within your template match for CustomerData
<xsl:template match="CustomerData">
...
<xsl:template match="inhouse">
....
</xsl:template>
....
</xsl:template>
You are not allowed to nest templates in this way. What you need to do is move your inhouse template out of the current template, but instead tell the XSLT processor to start looking for other templates at that point with xsl:apply-templates. Something like this structure
<xsl:template match="CustomerData">
...
<xsl:apply-templates select="inhouse" />
...
</xsl:template>
<xsl:template match="inhouse">
....
</xsl:template>
In fact, it could be slightly better to replace <xsl:apply-templates select="inhouse" /> with just <xsl:apply-templates /> as this would handle the case where you have other elements other than inhouse you wanted to match.
Try this XSLT
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="CustomerData">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simple" page-height="29.7cm" page-width="21.0cm" margin-left="1.5cm" margin-right="1.5cm" margin-top="0cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="0cm"/>
<fo:region-after extent="0cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simple">
<fo:flow flow-name="xsl-region-body">
<fo:block font-family="Arial" font-size="8.5pt" font-weight="normal">
abc
</fo:block>
<xsl:apply-templates />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="inhouse">
<fo:block color="#053679">
xxx
</fo:block>
</xsl:template>
</xsl:stylesheet>