[ 
https://issues.apache.org/jira/browse/FOP-3290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18063644#comment-18063644
 ] 

Joao Goncalves commented on FOP-3290:
-------------------------------------

[https://github.com/apache/xmlgraphics-fop/commit/3d6e7c5d631117987cdc82b92c4544b114c77021]

[~oleksandr92] add the following to your conf: 
*<force-uri-basic-link>true</force-uri-basic-link>* inside the *<renderer 
mime="application/pdf">* 

> Issue with <fo:basic-link> to external .pdf files
> -------------------------------------------------
>
>                 Key: FOP-3290
>                 URL: https://issues.apache.org/jira/browse/FOP-3290
>             Project: FOP
>          Issue Type: Bug
>    Affects Versions: 2.11
>            Reporter: Oleksandr
>            Assignee: Joao Goncalves
>            Priority: Major
>         Attachments: broken_pdf_link_example.zip
>
>
> h3. *Description*
> When generating a PDF using XSL-FO, the links to external local {{.pdf}} 
> files behave differently from the links to files with another extensions ( 
> .png, .txt etc ). In some PDF viewes ( for example in Chrome PDF viewer ) 
> when a user clicks such a link the target file is not opened. If the same 
> link points to a {{.png or .txt}} file, it works properly ( the targer file 
> is being opened).
> h3. Steps to Reproduce
>  # Use the following XSL-FO to generate a PDF:
> {code:java}
> <fo:basic-link show-destination="new" external-destination="targetFile.pdf">
>    Test Link (PDF)
> </fo:basic-link>
> <fo:basic-link show-destination="new" external-destination="targetFile.png">
>    Test Link (PNG)
> </fo:basic-link>{code}
>  # Open the resulting PDF in Chrome PDF viewer
>  # Click the PNG link (the PNG file is opened, as expected)
>  # Click the PDF link
> *Actual Result:* the targetFile.pdf file is not opened
> *Expected Result:* The targetFile.pdf is opened ( the PDF link behaves like 
> the PNG link)
> Some PDF viewers handles the PDF link correctly ( for example, Acrobat Reader 
> on Windows 10 )
> h3. Technical Analysis
> The current implementation seems to have a hardcoded "special case" for files 
> ending in {{.pdf in }}{{PDFFactory#getExternalAction().}}
> It forces creation of a {{PDFGoToRemote}} action of all external .pdf files. 
> For all other extensions it returns {{PDFUri}} which works correctly
> I've tested other variations of link url, but none of them works for link to 
> .PDF file
>  
> {code:java}
> url('targetFile.pdf')      
> file:///targetFile.pdf   
> targetFile.pdf#page=1   
> etc {code}
>  
> The issue doesn't appears in Apache FOP version 2.7 ( before the following 
> code was added to PDFFactory.java
> {code:java}
> if (scheme == null && filename.toLowerCase().endsWith(".pdf")) {
>    scheme = "file";
> }{code}
>  
> Here is the full sample XSL-FO code and the archive with generated PDFs
> [^broken_pdf_link_example.zip]
> {code:java}
> <?xml version="1.0" encoding="UTF-8"?>
> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
>     <fo:layout-master-set>
>         <fo:simple-page-master master-name="A4" page-height="29.7cm" 
> page-width="21cm" margin="2cm">
>             <fo:region-body/>
>         </fo:simple-page-master>
>     </fo:layout-master-set>
>     <fo:page-sequence master-reference="A4">
>         <fo:flow flow-name="xsl-region-body">
>             <fo:block font-family="sans-serif" font-size="12pt">
>                 <fo:block margin-bottom="10pt">
>                     1. PDF Link (Expected to open file):
>                     <fo:basic-link external-destination="targetFile.pdf" 
> color="blue" text-decoration="underline">
>                         targetFile.pdf
>                     </fo:basic-link>
>                 </fo:block>
>                 <fo:block>
>                     2. Image Link (Working correctly):
>                     <fo:basic-link external-destination="targetFile.png" 
> color="blue" text-decoration="underline">
>                         targetFile.png
>                     </fo:basic-link>
>                 </fo:block>
>             </fo:block>
>         </fo:flow>
>     </fo:page-sequence>
> </fo:root> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to