Our clients have asked us a question,
Can you please help to solve it?
The following is the content of the customer’s inquiry:
We found that the page number of ODT will not increase with the number of pages, but will remain at 1.
Could you please help to solve this problem?
The attachment is JRXML and the generated report.
Thanks!
https://www.dropbox.com/s/as03qfjdff96xc5/QIK110P.jrxml?dl=0
https://www.dropbox.com/s/9kdll76y38jot10/QIK160P.jrxml?dl=0
@accesssoft You should use AWExporterParameter.RECOGNIZE_FIELDS option and the appropriate MS Word field code { PAGE }
in your report.
Hi Peggy,
I’ve changed my JRXML to use {PAGE} field code for current page number and set RECOGNIZE_FIELDS to true, but the output odt document gives null value on current page number. Please refer to code snippet images below and attached files.
https://www.dropbox.com/scl/fi/oeae2rp6fg8myy7omiczg/QIK110P-24.odt?dl=0&rlkey=wkihh4p03a3q1e6pkeck9k40f
https://www.dropbox.com/s/wq8cz8n8wsu4gba/QIK110P.jrxml?dl=0
cc.png (100.3 KB)
bb.png (137.2 KB)
aa.png (246.7 KB)
Hi @accesssoft
I checked your jrxml file and find $V{PAGE_NUMBER}
and $V{PAGE}
field.
But AW for JasperReport create and set $V{PAGE}
and $V{NUMPAGES}
field.
It means that your $V{PAGE_NUMBER}
field has null value.
Currently JASPER REPORT cannot recognize the number of changes in $V{PAGE} and $NUMPAGES}
I’m adding two variables now, PAGE and NUMPAGES , but they all show as NULL
https://www.dropbox.com/s/wq8cz8n8wsu4gba/QIK110P.jrxml?dl=0
Hi @accesssoft
I find working expression from our tests
<textFieldExpression><![CDATA["Page {PAGE} of {NUMPAGES}"]]></textFieldExpression>
It means that you can replace $V{PAGE_NUMBER} to {NUMPAGES} and $V{PAGE} to {PAGE}
It doesn’t require adding variables
Stack Trace:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'text'.
One of '{"http://jasperreports.sourceforge.net/jasperreports":textFieldExpression,
"http://jasperreports.sourceforge.net/jasperreports":patternExpression,
"http://jasperreports.sourceforge.net/jasperreports":anchorNameExpression,
"http://jasperreports.sourceforge.net/jasperreports":hyperlinkReferenceExpression,
"http://jasperreports.sourceforge.net/jasperreports":hyperlinkAnchorExpression,
"http://jasperreports.sourceforge.net/jasperreports":hyperlinkPageExpression,
"http://jasperreports.sourceforge.net/jasperreports":hyperlinkTooltipExpression,
"http://jasperreports.sourceforge.net/jasperreports":hyperlinkParameter}' is expected.
<textFieldExpression><![CDATA[{NUMPAGES}]]></textFieldExpression>
<textFieldExpression><![CDATA["{NUMPAGES}"]]></textFieldExpression>
it shows error.
Hi @accesssoft
For printing Page number please use static text and delete unused Page variable,
<staticText>
<reportElement x="686" y="60" width="24" height="17"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="標楷體" size="12"/>
</textElement>
<text><![CDATA[{PAGE}]]></text>
</staticText>
In previous cases PAGE_NUMBER is printed right. You can use the old text field with $V{PAGE_NUMBER} or static text with {NUMPAGES}
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
<text><![CDATA[{NUMPAGES}]]></text>
we try below way still null.
PageSetup pageSetup = doc.getFirstSection().getPageSetup();
pageSetup.setRestartPageNumbering(true);
pageSetup.setPageStartingNumber(1);
Also, doc.updateFields();
still failed.
@accesssoft It looks like you postprocess the document using Aspose.Words for Java, right? Could you please attach the document, which is the input for Aspose.Words.Document?
Could you please clarify what is null
?
Do you get an exception?
StaticText is sucessful.
However, currently there is another problem, one page has page header blank page.
here is dropbox link https://www.dropbox.com/scl/fo/845xioom3svtqugka869x/h?dl=0&rlkey=u211zvuientwi07dcdoh35son
Peggy
@accesssoft We will check the issue and provide you more information.
FYI @anatoly.sidorenko
Hi @accesssoft
For printing PAGE_NUMBER please use static text and delete unused $V{PAGE_NUMBER} variable,
<staticText>
<reportElement x="784" y="38" width="17" height="17"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="標楷體" size="12"/>
</textElement>
<text><![CDATA[{ NUMPAGES }]]></text>
</staticText>
The page header on the blank page could be happen on many reason.
I thinking about the Page Break and how it can split tables to different pages.