Links in PDF Output

John's Avatar


24 Aug, 2016 03:27 PM

I am working on a course catalog using the course catalog project in Cascade Exchange as a starting point. I am using $_SerializerTool.serialize to write some of the content in the PDF so that it maintains the formatting and links. It works fine except that the links aren't rewritten properly when the PDF is output. For example, <a href="site://Undergraduate Catalog/undergraduatecatalog/accounting/index">Accounting</a> from the XML gets written exactly like that in the PDF instead of <a href="/undergraduatecatalog/accounting/index.html">Accounting</a>. Therefore, the link doesn't work in the PDF.

I looked inside the xhtml2fo2pdf XSLT file that came with the course catalog project and I see that there is some code to rewrite links, but it doesn't seem to take into account links pulled from within the CMS. So it simply writes the href as it is in the XML.

Am I missing something or do I have to modify xhtml2fo2pdf to rewrite an internal link properly the way it does for web pages?

  1. 1 Posted by Ryan Griffith on 25 Aug, 2016 03:56 PM

    Ryan Griffith's Avatar

    Hi John,

    I recall seeing this issue in the past and worked on a proposed solution to help with same-site and cross-site link handling. The updated XSLT Format for generating PDFs can be found here.

    Specifically, what you would do is generate a hidden <div> that contains the current page's Site and this PDF format uses that to append a URL to same-site links; otherwise, the cross-site link will have the Site's URL appended to it.

    The PDF Format has an example XSLT in the comments at the top to generate the hidden container, but you could also use the following Velocity:

    <div id="CURRENT-SITE:${currentPageSiteName}"></div>

    Please let me know if you have any questions.


  2. 2 Posted by John on 25 Aug, 2016 06:50 PM

    John's Avatar

    Hi, Ryan-

    So just to clarify, I should put the content inside this div in the format section of any template region that may contain links that will be output in the PDF, correct?

    ----- Original Message -----

  3. 3 Posted by Ryan Griffith on 26 Aug, 2016 01:19 PM

    Ryan Griffith's Avatar

    Hi John,

    Correct. For any "PDF template/output" you would want to have a "current site" region which has the Velocity Format I mentioned previously applied to it.

    When the PDF XSLT I linked to runs it will locate that hidden <div> and use the site name so it knows what the current site is.

    Please let me know if you have any questions.


Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM