Column-count overflowing down (XSL-FO + Antenna House Formatter) - xslt

I am working with XSL-FO in combination with the Antenna House Formatter (V6) where I have a block-container with column-count: 3 on it. The problem is the overflowing content does not go to the right but instead goes below it. I can "fix" the issue by creating more columns and increasing the width of the block-container but I dislike like that as it's a hack more than anything.
I have illustrated what it does and what I want:
Here is my document:
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" xmlns:lxslt="http://xml.apache.org/xslt" xmlns:xlink="http://www.w3.org/1999/xlink">
<fo:layout-master-set>
<fo:simple-page-master master-name="id0" page-width="210mm" page-height="200mm" axf:crop-offset="0mm" axf:bleed="0mm">
<fo:region-body/>
<fo:region-before extent="0cm"/>
<fo:region-after extent="0cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="id0">
<fo:flow flow-name="xsl-region-body">
<fo:block-container background-color="cmyk(0,0.87,0.83,0.3)" height="50mm" width="210mm" column-count="3" column-gap="1mm">
<fo:block hyphenate="true" language="da">
<fo:block-container width="70mm">
<fo:block font-size="15pt" line-height="20pt">
<fo:inline linefeed-treatment="preserve" white-space-treatment="ignore-if-surrounding-linefeed" font-family="DINRegular" color="cmyk(0.1,0.13,0.08,0.8)" font-size="15pt">Idet antallet af redigerbare felter per sag begrænses af afhængigheden til ejendomstype og antal ejendomstypebeskrivelser valgt, så foreslår vi, at sagsdataene vedligeholdes under én og samme fane, Data. Derfor er rækkefølgen hvormed brugeren bør vedligeholde dataene som følger. For at vedligeholde data på en sag skal man klikke på sagen og herefter på fanen Ejendomsdata. Dette åbner fanen Data, som er den første under Ejendomsdata.</fo:inline>
</fo:block>
</fo:block-container>
<fo:block-container width="70mm">
<fo:block font-size="20pt" line-height="25pt">
<fo:inline linefeed-treatment="preserve" white-space-treatment="ignore-if-surrounding-linefeed" font-family="DINLight" color="cmyk(0,0,0,1)" font-size="20pt">Endvidere er der afhængigheder mellem valgte ejendomstype og de data, der kan vedligeholdes under Vilkår og Økonomi, samt mellem antallet af (og hvilke) valgte ejendomstypebeskrivelser og de data der kan vedligeholdes hertil. Endnu en årsag til, at vi foreslår, at sagsdataene vedligeholdes under én og samme fane er, at eventuelle ændringer, som foretages på én fane og gemmes, kan have konsekvenser for indholdet under andre faner.</fo:inline>
</fo:block>
</fo:block-container>
</fo:block>
</fo:block-container>
</fo:flow>
</fo:page-sequence>
</fo:root>

Is the above format of display Ok?

Related

XSL-FO footer only in first page (2-page rtf doc)

I am trying to set a footer only in the first page of a RTF document.
Approach
I defined two regions to show one in the first page and the other in the rest of pages.
Once it is done, I could just remove the second footer text to achieve my goal (the generated rtf document only has two pages).
Result
Unfortunately with the transformation below I am getting the "Rest of pages footer" in both pages. It seems XSL-FO never catches the matching criteria for page-position="first".
I also tried a similar approach with odd-or-even="odd" in the conditional-page-master-reference with the same result.
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="first"
page-height="29.7cm" page-width="21.0cm" margin-left="2.54cm"
margin-right="2.54cm" margin-top="1cm" margin-bottom="2.54cm">
<fo:region-body margin-top="1.54cm"/>
<fo:region-after region-name="footer-first" extent="2cm" display-align="after"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="rest"
page-height="29.7cm" page-width="21.0cm" margin-left="2.54cm"
margin-right="2.54cm" margin-top="1cm" margin-bottom="2.54cm">
<fo:region-body margin-top="1.54cm"/>
<fo:region-after region-name="footer-rest" extent="2cm" display-align="after" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="document">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="first" />
<fo:conditional-page-master-reference page-position="rest" master-reference="rest" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<xsl:template match="WC">
<xsl:variable name="id.wc">id_<xsl:value-of select="normalize-space(Id/text())"/>
</xsl:variable>
<fo:page-sequence master-reference="document"
padding-top="1cm" initial-page-number="1">
<fo:static-content flow-name="footer-first">
<fo:block padding-top="10pt" font-size="8">
<fo:inline color="grey">
First page footer
</fo:inline>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="footer-rest">
<fo:block text-align-last="center">Rest of pages footer</fo:block>
</fo:static-content>
<!-- Body continues... -->
FOP's RTF output supports only a single page master. See https://xmlgraphics.apache.org/fop/2.6/output.html#rtf
FWIW, you can get the footers with AH Formatter using the free-but-unsupported Word output option (see https://www.antennahouse.com/microsoft-word-output):

How to create border in A4 page and fo:block rounded corner in using - XSL-FO

How to create a border in the A4 page and How to make rounded fo:block.
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4" page-height="11.40in" page-width="8.27in" margin-top="0.30in" margin-bottom=".030in" margin-left="0.30in" margin-right="0.30in">
<fo:region-body region-name="body" margin=".30in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="body">
<fo:block text-align="center" border="1pt" border-style="solid">
How to create rounded border
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
I have tested following XSL-FO file via FOP 2.5.
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4" page-height="11.40in" page-width="8.27in" margin-top="0.30in" margin-bottom=".030in" margin-left="0.30in" margin-right="0.30in">
<fo:region-body region-name="body" margin=".30in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="body">
<fo:block text-align="center" border="1pt" border-style="solid" fox:border-radius="10pt 15pt">
Hello Word!
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
[The output snapshot]
[Sample command-line]
[Oxygen Transformation Scenario]
[Oxygen 21.1 with FOP 2.3 build result]
fo:region-body can have border properties. See https://www.w3.org/TR/xsl11/#fo_region-body.
Rounded corners are not in the XSL 1.1 Recommendation. However, your XSL formatter probably has an extension for rounded corners:
Antenna House has axf:border-radius and related properties (see https://www.antenna.co.jp/AHF/help/v70e/ahf-ext.html#axf.border-radius).
FOP has fox:border-*-*-radius properties (see https://xmlgraphics.apache.org/fop/2.5/extensions.html#rounded-corners).

Thick border line issue in XSL FO Table - PDF Creation Using Apache FOP

i am trying to hide fo:table row or column lines based on the requirement from web application, so i used to set border-style="none" to fo:table-column or fo:table-row based on the need, but when i tried it,
either it creates dark lines in row's (if i hide column lines)
or creates dark lines in column's (if i hide row lines).
If column lines get hidden:
If row lines get hidden:
MY XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="pages">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simple"
page-height="8.5in" page-width="11in" margin-top=".5in"
margin-bottom=".5in" margin-left=".5in" margin-right=".5in">
<fo:region-body margin-top="2cm" margin-bottom="2cm" />
<fo:region-before extent="2cm" overflow="hidden" />
<fo:region-after extent="1cm" overflow="hidden" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simple"
initial-page-number="1">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="13.0pt" font-family="serif"
padding-after="2.0pt" space-before="4.0pt" text-align="center"
border-bottom-style="solid" border-bottom-width="1.0pt">
<fo:block>IF COLUMN LINES HIDED</fo:block>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="12.0pt" font-family="sans-serif"
padding-after="2.0pt" space-before="2.0pt" text-align="center"
border-top-style="solid" border-bottom-width="1.0pt">
<xsl:text>Page</xsl:text>
<fo:page-number />
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="page-body" />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="page-body">
<fo:block text-align="center" break-before="page">
<fo:table table-layout="fixed" width="100%"
border-style="solid">
<fo:table-column border-style="solid"/>
<fo:table-column border-style="solid"/>
<fo:table-column border-style="solid"/>
<!-- For hiding column lines -->
<!-- <fo:table-column border-style="none"/> -->
<!-- <fo:table-column border-style="none"/> -->
<!-- <fo:table-column border-style="none"/> -->
<fo:table-header>
<xsl:apply-templates select="table-header" />
</fo:table-header>
<fo:table-body>
<xsl:apply-templates select="table-data" />
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>
<xsl:template match="table-header">
<fo:table-row keep-together.within-page="always"
border-style="solid">
<fo:table-cell>
<fo:block font-size="10pt" font-family="sans-serif"
padding-top="3pt">
<xsl:value-of select="column-one"></xsl:value-of>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="10pt" font-family="sans-serif"
padding-top="3pt">
<xsl:value-of select="column-two"></xsl:value-of>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="10pt" font-family="sans-serif"
padding-top="3pt">
<xsl:value-of select="column-three"></xsl:value-of>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="table-data">
<fo:table-row keep-together.within-page="always"
border-style="none">
<!-- For showing row lines -->
<!-- <fo:table-row keep-together.within-page="always" -->
<!-- border-style="solid"> -->
<fo:table-cell>
<fo:block font-size="10pt" font-family="sans-serif"
padding-top="3pt">
<xsl:value-of select="column-one"></xsl:value-of>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="10pt" font-family="sans-serif"
padding-top="3pt">
<xsl:if test="number(column-two) = number(column-two)">
<xsl:value-of select="format-number(translate(column-two, ',','.'), '#,###.##')"></xsl:value-of>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-size="10pt" font-family="sans-serif"
padding-top="3pt">
<xsl:value-of select="column-three"></xsl:value-of>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
MY XML:
<?xml version="1.0" encoding="UTF-8"?>
<pages>
<page-body>
<table-header>
<column-one>Column One</column-one>
<column-two>Column Two</column-two>
<column-three>Column Three</column-three>
</table-header>
<table-data>
<column-one>One</column-one>
<column-two>5000</column-two>
<column-three>Three</column-three>
</table-data>
<table-data>
<column-one>One</column-one>
<column-two>5000</column-two>
<column-three>Three</column-three>
</table-data>
<table-data>
<column-one>One</column-one>
<column-two>0</column-two>
<column-three>Three</column-three>
</table-data>
<table-data>
<column-one>One</column-one>
<column-two>0</column-two>
<column-three>Four</column-three>
</table-data>
<table-data>
<column-one>One</column-one>
<column-two>2000</column-two>
<column-three>Four</column-three>
</table-data>
<table-data>
<column-one>One</column-one>
<column-two>1234</column-two>
<column-three>Five</column-three>
</table-data>
<table-data>
<column-one>One</column-one>
<column-two>5666</column-two>
<column-three>Five</column-three>
</table-data>
<table-data>
<column-one>One</column-one>
<column-two>5666</column-two>
<column-three>Five</column-three>
</table-data>
</page-body>
</pages>
I am using these xml and xsl files to generate PDF using apache fop, Is there any problem in my code?
Unfortunately, this sort of thing crops up from time to time in FO development involving FOP rendering.
For your answer, please see Section 6.9 of xmlgraphics.apache.org's FAQ re anti-aliasing and Acrobat.
Notice that if you play with the zoom factor in Acrobat, the problem will disappear/reappear depending on the setting.
Also note that if you try your example with RenderX (a.k.a XEP), this won't happen. They've apparently figured out (or never had) the problem.
One of the perils of trying to get away with a non-commercial FO product. (Not that something has to be commercial to be good, of course, but it's just fact that commercial FO processors are better and more powerful than FOP, though FOP is improving, albeit slowly.)
If you have to continue using FOP, make sure you're on the latest version (see this pin). Some important benefit to be had with 2.4.
ADDENDUM (Usage of SVG):
You can avoid this FOP bugginess by dynamically-built-out SVG markup.
Here's an example of the kind of markup you'd have to generate to get a PDF table by this method:
<fo:instream-foreign-object>
<svg:svg width="1000%" height="1000%">
<svg:g id='rowGroup' transform='translate(0, 0)' role="table">
<svg:text x='30' y='30' font-size='18px' font-weight='bold' fill='crimson' text-anchor='middle' role="row">
<svg:tspan role="columnheader" x='100'>Sales</svg:tspan>
<svg:tspan role="columnheader" x='200'>Expenses</svg:tspan>
<svg:tspan role="columnheader" x='300'>Net</svg:tspan>
</svg:text>
<svg:rect x='30' y='40' width='310' height='1' fill='black'/>
<svg:text x='30' y='30' font-size='18px' text-anchor='middle' role="row">
<svg:tspan id="q1" role="rowheader" x='30' dy='1.5em' font-weight='bold' fill='crimson' text-anchor='start'>Q1</svg:tspan>
<svg:tspan role="cell" x='100'>$223</svg:tspan>
<svg:tspan role="cell" x='200'>$195</svg:tspan>
<svg:tspan role="cell" x='300'>$28</svg:tspan>
</svg:text>
<svg:rect x='30' y='60' width='310' height='1' fill='black'/>
<svg:text x='30' y='50' font-size='18px' text-anchor='middle' role="row">
<svg:tspan id="q2" role="rowheader" x='30' dy='1.5em' font-weight='bold' fill='crimson' text-anchor='start'>Q2</svg:tspan>
<svg:tspan role="cell" x='100'>$295</svg:tspan>
<svg:tspan role="cell" x='200'>$263</svg:tspan>
<svg:tspan role="cell" x='300'>$32</svg:tspan>
</svg:text>
<svg:rect x='30' y='80' width='310' height='1' fill='black'/>
<svg:text x='30' y='70' font-size='18px' text-anchor='middle' role="row">
<svg:tspan id="q3" role="rowheader" x='30' dy='1.5em' font-weight='bold' fill='crimson' text-anchor='start'>Q3</svg:tspan>
<svg:tspan role="cell" x='100'>$951</svg:tspan>
<svg:tspan role="cell" x='200'>$232</svg:tspan>
<svg:tspan role="cell" x='300'>$719</svg:tspan>
</svg:text>
<svg:rect x='30' y='100' width='310' height='1' fill='black'/>
<svg:text x='30' y='90' font-size='18px' text-anchor='middle' role="row">
<svg:tspan id="q4" role="rowheader" x='30' dy='1.5em' font-weight='bold' fill='crimson' text-anchor='start'>Q4</svg:tspan>
<svg:tspan role="cell" x='100'>$823</svg:tspan>
<svg:tspan role="cell" x='200'>$175</svg:tspan>
<svg:tspan role="cell" x='300'>$648</svg:tspan>
</svg:text>
<svg:rect x='30' y='120' width='310' height='1' fill='black'/>
</svg:g>
</svg:svg>
</fo:instream-foreign-object>
I leave it to you to dynamicize the FO creation for your particular case, but this ought to teach you how to build tables this way.
You can easily achieve the effects you desire by drawing the borders as SVG polygons, which is where Kevin was going with this (although I believe he was speaking of the code inside the RenderX engine. My solution externalizes that via embedded SVG creation.) Of course, the <svg:rect> tag is a form of polygon, and that's what you'd use to render borders.
Remember to specify the SVG namespace on your <xsl:stylesheet> tag if you're going to attempt this.
xmlns:svg="http://www.w3.org/2000/svg"
Check out this recently merged patch (merged 2020-12-29), which seems to fix this problem for me:
https://issues.apache.org/jira/browse/FOP-2536 (Varying table border thickness in PDF output)
Revision 1884907: FOP-2536: Allow overpaint of PDF border
From the Apache FOP 2.6 you can to set the following parameter into the configuration file (by default fop.xconf):
<table-border-overpaint>true</table-border-overpaint>
This option may to make your borders thicker, but fix an issue:
https://xmlgraphics.apache.org/fop/faq.html#acrobat-anti-aliasing
Also this issue is registered as Chromium Pdf rendering bug:
https://bugs.chromium.org/p/chromium/issues/detail?id=500023

FOP first page without page number

I have the xsl-fo template:
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master margin-right="1cm"
margin-left="2.7cm" margin-bottom="2cm" margin-top="2cm"
page-width="21.5cm" page-height="29.7cm" master-name="first">
<fo:region-body margin-right="1cm" margin-left="0cm" />
<fo:region-after region-name="xsl-region-after" display-align="before" extent="0.7in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="first">
<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="center" font-size="10pt">
<fo:page-number />
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="rootElement" />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
All works excellent, but first page have a page number.
I do not need number on first page.
Thanks y'all!
You have to create a separate page-sequence-master for the first page, that does not include the page number. Then use a statement like this to specify which master will be used for each page of the book:
<fo:page-sequence-master master-name="chapter">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="page_first" page-position="first"/>
<fo:conditional-page-master-reference master-reference="page_even" odd-or-even="even"/>
<fo:conditional-page-master-reference master-reference="page_odd" odd-or-even="odd"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
(copied from one of my projects, so you'll have to adapt it to your structure)

Aligning an element to the right using XSL-FO, Apache FOP

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.