Hello everyone,
It turns out, it's not exactly what I described in my first message that's
causing the issue but more the fact that a linefeed is spanning two pages with
different left-right margin layouts.
It's seems to be an issue with FOP :
-
https://issues.apache.org/jira/browse/FOP-2716?jql=project%20%3D%20FOP%20AND%20resolution%20%3D%20Unresolved%20AND%20text%20~%20%22linefeed%22%20ORDER%20BY%20priority%20DESC
-
https://issues.apache.org/jira/browse/FOP-2685?jql=project%20%3D%20FOP%20AND%20resolution%20%3D%20Unresolved%20AND%20text%20~%20%22linefeed%22%20ORDER%20BY%20priority%20DESC
Does someone has a workaround to suggest?
Someone suggested me to replace linefeed characters in my text area with an
empty block <fo:block/>.
Problem is, I don't know what character to look for (xml is encoded in utf-8 on
a windows machine).
Let's say I have the xml input:
<textArea> TEXT WITH LINE-BREAKS
END OF TEXT WITH LINE-BREAKS </textArea>
The XPath expressions:
- contains(//textArea,'
') or other combination of 
and 
 return false
- //textArea/text() return only 1 text node
I'm not sure exactly how to achieve that fix.
Thank you for your help,
Best regards,
Mathias
-----Original Message-----
From: Mathias Leclercq <Mathias(_dot_)Leclercq(_at_)biion(_dot_)com>
Sent: Thursday, June 28, 2018 8:33 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [XSL-FO] Linebreaks on a page break (linefeed-treatment)
Hi everyone,
I'm using XSL-T and XSL-FO to produce PDF (A4) reports using data from forms
filled by user in a third-party software (that output XML). Users can have any
sorts of input, included large text area they can fill as they want (no control
over the content size).
----------------------------------------------------------------------------------------------------------
I'm using
- XSLT Engine: Altova (built-in RaptorXML XSLT engine) for XSL development
- XSLT version 1.0
- FOP Processor: Apache FOP 1.0
----------------------------------------------------------------------------------------------------------
The issue I came across is that whenever the text area is filled with enough
data to cause a page break, and when there are linebreaks at the exact moment
the page break occurs, the FOP processor issues a null pointer exception. Below
is the part of the XSL-FO that is causing an issue.
The linefeed-treatment="preserve" is to keep the format from the form to the
PDF and the keep-together.within-page="always" ("auto" here to show the issue)
is a workaround I found to resolve this issue but that I cannot keep because
data is lost when the text span more than 1 page.
Is there a problem somewhere in my code? is it related to the FOP processor?
I can provide with the complete files if necessary
Thank you very much for any help you can provide
-----------------------------------------------------------------------------------------------------
XSL-FO after transformation
-----------------------------------------------------------------------------------------------------
<fo:block space-before="5mm" text-align="justify">
<fo:block linefeed-treatment="preserve"
keep-together.within-page="auto">
<fo:block>
<fo:inline/>
<fo:inline> TEST WITH LOTS OF LINEBREAKS
********************************************
somwehere here there's a page break
********************************************
END OF TEST WITH LINEBREAKS </fo:inline>
</fo:block>
</fo:block>
</fo:block>
-----------------------------------------------------------------------------------------------------
XML from third-party software (trimmed)
-----------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<FM024_BIL_RapportConsultation>
<ZTXT_lettre style="txtArea" toPrint="1"> TEST WITH LOTS OF LINEBREAKS
END OF TEST WITH LINEBREAKS </ZTXT_lettre>
</FM024_BIL_RapportConsultation>
-----------------------------------------------------------------------------------------------------
XSL-T template to match the @style = 'txtArea'
-----------------------------------------------------------------------------------------------------
<xsl:template match="*[attribute::style='txtArea']">
<xsl:param name="pLang" select="$gLang"/>
<xsl:param name="pTitleTemplate"/>
<xsl:param name="pKeepTogetherWithinPage" select="'always'"/>
<xsl:param name="pStartWith" select="''"/>
<xsl:if test="self::node()/text() != ''"> <!-- display content only if
text area is not empty -->
<fo:block linefeed-treatment="preserve"
keep-together.within-page="{$pKeepTogetherWithinPage}">
<xsl:if test="$pTitleTemplate != ''">
<fo:block>
<xsl:copy-of select="$pTitleTemplate"/>
</fo:block>
</xsl:if>
<fo:block>
<xsl:call-template name="gLangString">
<xsl:with-param name="pLang"
select="$pLang"/>
<xsl:with-param name="pString"
select="$pStartWith"/>
</xsl:call-template>
<fo:inline>
<xsl:value-of
select="self::node()/text()"/>
</fo:inline>
</fo:block>
</fo:block>
</xsl:if>
</xsl:template>
-----------------------------------------------------------------------------------------------------
Most of the complete XSL-FO (removed all the unrelated stuff)
-----------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="coverPage" margin="5mm"
page-height="297mm" page-width="210mm" reference-orientation="0"
writing-mode="lr-tb">
<fo:region-body margin-top="25mm" margin-bottom="25mm"
margin-left="45mm" margin-right="5mm"/>
<fo:region-after extent="20mm" precedence="true"
display-align="before"/>
<fo:region-start extent="40mm"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="repeatablePage"
margin="5mm" page-height="297mm" page-width="210mm" reference-orientation="0"
writing-mode="lr-tb">
<fo:region-body margin-top="30mm" margin-bottom="25mm"
margin-left="20mm" margin-right="20mm"/>
<fo:region-after extent="20mm" precedence="true"
display-align="before"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="pageSequence">
<fo:single-page-master-reference
master-reference="coverPage"/>
<fo:repeatable-page-master-reference
master-reference="repeatablePage" maximum-repeats="no-limit"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="pageSequence"
font-family="sans-serif" font-weight="normal">
<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="right" font-size="10"
color="#083E70">
Page <fo:page-number/> de
<fo:page-number-citation ref-id="endDoc"/></fo:block>
<fo:block text-align="center" font-size="8"
color="#083E70" space-before="8mm">
<fo:block>ADRESS LINE 1</fo:block>
<fo:block>ADRESS LINE 2</fo:block>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-start">
<fo:block/>
<fo:block-container color="#083E70"
border-end-color="#083E70" border-end-width="1pt" border-end-style="solid"
block-progression-dimension="235mm">
<fo:block/>
<fo:block space-before="10mm"
space-after="10mm" font-weight="bold" text-decoration="underline"/>
</fo:block-container>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" font-size="10pt">
<fo:block space-before="5mm" text-align="justify"
font-family="monospace">
<fo:block linefeed-treatment="preserve"
keep-together.within-page="always">
<fo:block>
<fo:inline/>
<fo:inline> TEST WITH LOTS OF
LINEBREAKS
END OF TEST WITH LINEBREAKS </fo:inline>
</fo:block>
</fo:block>
</fo:block>
<fo:block id="endDoc"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--