[ https://issues.apache.org/jira/browse/FOP-2813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18018742#comment-18018742 ]
Adrian Bird commented on FOP-2813: ---------------------------------- I came across this problem using FOP 2.11 on Windows 11. Although the original description is good for the test case I did some more investigation. >From my investigation the issue only occurs in the following circumstances: _A page contains a fo:basic-link that references a page that contains a fo:page-number-citation/fo:page-number-citation-last, and that page number citation references a page later in the document._ In this situation clicking on the link jumps to the first page in the document. But if the page number citation references a page earlier in the document then clicking on the link jumps to the correct page. I produced 2 test cases, 1 that fails (LinkFails.fo) and 1 that works (LinkWorks.fo) and they both have the same basic structure: Page 1 (in the failing case the link points to this first page) Page 2 contains the fo:basic-link Page 3 contains a fo:page-number-citation (in the failing case this references the last page. In the working case this references the first page) Page 4 is the last page Clicking the link in LinkFails.pdf take you to the first page. Clicking the link in LinkWorks.pdf takes you to Page 3, the expected page. To confirm the difference between the 2 files I ran the, simple, Windows fc (fileCompare) command (see Diff_fo.txt). I also produced the Area Tree XML format for both cases and then produced PDFs for both. Both PDFs had the issue in that the link pointed to the first page. I compared the 2 Area Tree outputs, using Windows fc command, and the only difference was in the value of the fo:page-number-citation: '4' for the failing one and '1' for the working one (see Diff_at.txt). Given this was the only difference it seems reasonable that both PDFs are wrong, although it does indicate that the processing is different when using the Area Tree XML format compared to directly generating the PDF from the FO file. I also tried using the Intermediate Format but that doesn't seem to support links. These are the commands I ran: {code:java} @echo Working Example - generate PDF directly call %FOP_HOME%/fop -v -fo LinkWorks.fo -pdf LinkWorks.pdf @echo Working Example - generate Area Tree XML call %FOP_HOME%/fop -v -fo LinkWorks.fo -at application/pdf LinkWorks_at.xml @echo Working Example - generate PDF from Area Tree XML call %FOP_HOME%/fop -v -atin LinkWorks_at.xml -pdf LinkWorks_at.pdf @echo Failing Example - generate PDF directly call %FOP_HOME%/fop -v -fo LinkFails.fo -pdf LinkFails.pdf @echo Failing Example - generate Area Tree XML call %FOP_HOME%/fop -v -fo LinkFails.fo -at application/pdf LinkFails_at.xml @echo Failing Example - generate PDF from Area Tree XML call %FOP_HOME%/fop -v -atin LinkFails_at.xml -pdf LinkFails_at.pdf @echo Compare .fo files fc LinkFails.fo LinkWorks.fo >Diff_fo.txt @echo Compare Area Tree XML files fc LinkFails_at.xml LinkWorks_at.xml >Diff_at.txt {code} and this is the output: {code:java} Working Example - generate PDF directly FOP Version 2.11 [INFO] FOUserAgent - Rendered page #1. [INFO] FOUserAgent - Rendered page #2. [INFO] FOUserAgent - Rendered page #3. [INFO] FOUserAgent - Rendered page #4. Working Example - generate Area Tree XML FOP Version 2.11 Working Example - generate PDF from Area Tree XML FOP Version 2.11 [INFO] FOUserAgent - Rendered page #1. [INFO] FOUserAgent - Rendered page #2. [INFO] FOUserAgent - Rendered page #3. [INFO] FOUserAgent - Rendered page #4. Failing Example - generate PDF directly FOP Version 2.11 [INFO] FOUserAgent - Rendered page #1. [INFO] FOUserAgent - Rendered page #2. [INFO] FOUserAgent - Rendered page #3. [INFO] FOUserAgent - Rendered page #4. Failing Example - generate Area Tree XML FOP Version 2.11 Failing Example - generate PDF from Area Tree XML FOP Version 2.11 [INFO] FOUserAgent - Rendered page #1. [INFO] FOUserAgent - Rendered page #2. [INFO] FOUserAgent - Rendered page #3. [INFO] FOUserAgent - Rendered page #4. Compare .fo files Compare Area Tree XML files{code} I've attached the following files: LinkFails.fo - FO source where the link fails LinkFails.pdf - PDF from file above LinkFails_at.xml - Area Tree XML form LinkFails.fo LinkFails_at.pdf - PDF from LinkFails_at.pdf Linkworks.fo - FO source where the link works LinkWorks.pdf - PDF from the file above LinkWorks_at.xml - Area Tree XML from LinkWorks.fo LinkWorks_at.pdf - PDF from the file above - the link fails in here Diff_fo.txt - Difference between the 2 .fo files (the difference is the value of the 'ref-id' attribute in the fo:page-number-citation element) Diff_at.xml - Difference between the 2 Area Tree XML files (the difference is the generated value of the fo:page-number-citation element) > Internal Links break when using page-number-citiation > ----------------------------------------------------- > > Key: FOP-2813 > URL: https://issues.apache.org/jira/browse/FOP-2813 > Project: FOP > Issue Type: Bug > Components: fo/block, fo/page > Environment: XALAN > XSL 2.0 > Reporter: Dennis > Priority: Major > Attachments: Diff_at.txt, Diff_fo.txt, LinkFails.fo, LinkFails.pdf, > LinkFails_at.pdf, LinkFails_at.xml, LinkWorks.fo, LinkWorks.pdf, > LinkWorks_at.pdf, LinkWorks_at.xml, minimal_report.xsl, out.pdf > > > Internal page links break when used in conjunction with > pager-number-citiation. > I made a minimal sheet which generates a ToC and 4 data sites. Links to > data1-data3 do not work. Link to data4 works. The breaking point is in the > footer with the call to "page-number-citiation-last" ("page-number-citiation" > breaks it too). All links to pages AFTER the call (In this case its the id of > data3) work. All before do not. > This issue is not limited to using page-number-citiation in static content > but also in page flow. As soon as an id is referenced via this call all > internal links that point to the id or any id before in the document break. > Stylesheet (Also attached with generated pdf): > {code:java} > <?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" > xmlns:java="http://xml.apache.org/xalan/java" > version="2.0"> > <xsl:output method="xml" indent="yes" encoding="utf-8"></xsl:output> > <xsl:template match="/"> > <fo:root> > <fo:layout-master-set> > <fo:simple-page-master master-name="A4-portrait" page-height="29.7cm" > page-width="21.0cm" margin="2cm"> > <fo:region-body margin-top="2.5cm" margin-bottom="0.1cm"/> > <fo:region-before extent="2.5cm"/> > <fo:region-after extent="0.1cm"/> > </fo:simple-page-master> > </fo:layout-master-set> > <fo:page-sequence master-reference="A4-portrait" id="toc"> > <fo:flow flow-name="xsl-region-body"> > <fo:block> > <fo:basic-link internal-destination="data1">data1</fo:basic-link> > </fo:block> > <fo:block> > <fo:basic-link internal-destination="data2">data2</fo:basic-link> > </fo:block> > <fo:block> > <fo:basic-link internal-destination="data3">data3</fo:basic-link> > </fo:block> > <fo:block> > <fo:basic-link internal-destination="data4">data4</fo:basic-link> > </fo:block> > </fo:flow> > </fo:page-sequence> > <fo:page-sequence master-reference="A4-portrait" id="data1"> > <xsl:call-template name="footer"/> > <xsl:call-template name="blob-template"> > <xsl:with-param name="blob">data 1</xsl:with-param> > </xsl:call-template> > </fo:page-sequence> > <fo:page-sequence master-reference="A4-portrait" id="data2"> > <xsl:call-template name="footer"/> > <xsl:call-template name="blob-template"> > <xsl:with-param name="blob">data 2</xsl:with-param> > </xsl:call-template> > </fo:page-sequence> > <fo:page-sequence master-reference="A4-portrait" id="data3"> > <xsl:call-template name="footer"/> > <xsl:call-template name="blob-template"> > <xsl:with-param name="blob">data 3</xsl:with-param> > </xsl:call-template> > </fo:page-sequence> > <fo:page-sequence master-reference="A4-portrait" id="data4"> > <xsl:call-template name="footer"/> > <xsl:call-template name="blob-template"> > <xsl:with-param name="blob">data 4</xsl:with-param> > </xsl:call-template> > </fo:page-sequence> > </fo:root> > </xsl:template> > <xsl:template name="blob-template"> > <xsl:param name="blob"></xsl:param> > <fo:flow flow-name="xsl-region-body"> > <fo:block> > <xsl:value-of select="$blob"/> > </fo:block> > </fo:flow> > </xsl:template> > <!-- ################# FOOTER ################################### --> > <xsl:template name="footer"> > <fo:static-content flow-name="xsl-region-after"> > <fo:block text-align="center"> > <fo:page-number/> / > <fo:page-number-citation-last ref-id="data3"/> > </fo:block> > </fo:static-content> > </xsl:template> > </xsl:stylesheet>{code} > Output when generating: > {code:java} > 2018-09-05 14:03:33,829 - WARN - The contents of fo:region-after on page 2 > exceed the available area in the block-progression direction by 11566 > millipoints. (No context info available) > 2018-09-05 14:03:33,835 - WARN - The contents of fo:region-after on page 3 > exceed the available area in the block-progression direction by 11566 > millipoints. (No context info available) > 2018-09-05 14:03:33,837 - WARN - The contents of fo:region-after on page 4 > exceed the available area in the block-progression direction by 11566 > millipoints. (No context info available) > 2018-09-05 14:03:33,840 - WARN - The contents of fo:region-after on page 5 > exceed the available area in the block-progression direction by 11566 > millipoints. (No context info available) > 2018-09-05 14:03:33,844 - INFO - Rendered page #1. > 2018-09-05 14:03:33,845 - INFO - Rendered page #2. > 2018-09-05 14:03:33,846 - INFO - Rendered page #3. > 2018-09-05 14:03:33,847 - INFO - Rendered page #4. > 2018-09-05 14:03:33,847 - INFO - Rendered page #5. > 2018-09-05 14:03:33,848 - WARN - 4 link targets could not be fully resolved > and now points to the top of the page or are dysfunctional.{code} -- This message was sent by Atlassian Jira (v8.20.10#820010)