<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Recently someone asked a great question, and great questions always get us thinking.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>They wanted to implement document navigation widgets like “Next Page” and “Previous Page”.<o:p></o:p></p><p class=MsoNormal>Now, if they had licensed XEP with PDF Forms support, this is easy because you can inject PDF Form elements (like fillable fields, combos and buttons) in the document. <o:p></o:p></p><p class=MsoNormal>You can also attach Javascript on such objects. Attaching a button in the PDF when pushed triggers Javascript engine in PDF to “turn the page” is easy.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>But they do not have the PDF Acroforms add-on to RenderX.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Not that I like *<b>not</b>* selling someone something, I thought about it for a minute. <o:p></o:p></p><p class=MsoNormal>I tried to think of an internal-destination/id scenario that may work, and there could very well be one … but I am not sure. <o:p></o:p></p><p class=MsoNormal>Maybe throwing markers throughput the document and some complicated scheme. <o:p></o:p></p><p class=MsoNormal>But why try to create something in XSL FO (which is not page aware)?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>One thing I did know, it would be easy in the XEP Intermediate Format to create it. It contains all there is to know about pages.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Let’s take a look at a few items in XEPOUT. First, what does it look like when there is an “anchor” something to latch onto?<o:p></o:p></p><p class=MsoNormal>Well that is pretty easy, something like this:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><xep:target x="0" y="792000" id="docnav-1" name="docnav-1"/><br><xep:target x="0" y="792000" id="rx:last@docnav-1" name="rx:last@docnav-1"/><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The “x” and “y” coordinates contain the upper left corner of the anchor.<o:p></o:p></p><p class=MsoNormal>The id and name are used internally to make a table of all the anchors.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Now, what about a link that goes to some internal destination?<o:p></o:p></p><p class=MsoNormal>Again, easy, something like this:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><xep:internal-link x-from="72000" y-from="736866" x-till="108000" y-till="747966"<br> destination-id="docnav-1" destination="docnav-1" destination-x="64800"<br> destination-y="727200"/><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The x-from, y-from, x-till, y-till are the bounding box of the clickable area.<o:p></o:p></p><p class=MsoNormal>The destination-id is the id to go look for in the document and display.<o:p></o:p></p><p class=MsoNormal>I am not going to go into some of the others, they are actually not that important.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Suffices to say that if the <xep:internal-link> area above is clicked (whose destination is “docnav-1”) , the point described by the <xep:target> above (whose id is “docnav-1”) would come into view. No matter where it is in the PDF.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Given that and a little knowledge of XEPOUT, we have everything we need to build something like a “page turner”. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>And so, here it is. A simple XSL that would inject images into a PDF along with links to turn the pages of a PDF. It operates against the XEPOUT format, modifying it before you would give it back to the formatter to output the final PDF. You can of course do you own thing here, change the images, place them elsewhere, skip certain pages. It doesn’t do anything special but put forward and back buttons on every page (except back on 1 and forward on the last). <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Any questions? Write us! Or discuss here. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><?xml version="1.0" encoding="UTF-8"?><br><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"<br> xmlns:xep="http://www.renderx.com/XEP/xep"><br> <!-- Not that you may have anything else named 'docnav-#', this is here so you can change the name of the id's inserted if you like --><br> <xsl:variable name="pagestr" select="'docnav-'"/><br> <!-- Get the total number of pages in the document --><br> <xsl:variable name="totpages" select="count(//xep:page)"/><br> <xsl:template match="xep:page"><br> <xep:page width="{@width}" height="{@height}" page-number="{@page-number}"<br> page-id="{@page-id}"><br> <!-- Add a destination on each page right after the xep:page --><br> <xsl:variable name="page-number" select="count(preceding-sibling::xep:page) + 1"/><br> <xsl:variable name="page-numid" select="concat($pagestr,$page-number)"/><br> <xsl:variable name="page-height" select="@height"/><br> <xep:target x="0" y="{$page-height}" id="{$page-numid}" name="{$page-numid}"/><br> <xep:target x="0" y="{$page-height}" id="rx:last@{$page-numid}"<br> name="rx:last@{$page-numid}"/><br> <!-- Output everything on the page --><br> <xsl:apply-templates/><br> <!-- Then add the navigation buttons with logic to not add back on page 1 nor forward on the last page --><br> <xsl:if test="$page-number < $totpages"><br> <xsl:variable name="forward-id" select="concat($pagestr,$page-number + 1)"/><br> <xep:image src="cliser://localhost/F:/Desktop%20Files/CoolTools/DocNav/forward.png"<br> type="image/png" x-from="504000" y-from="739350" scale-x="0.5" scale-y="0.5"<br> width="36000" height="15000"/><br> <xep:internal-link x-from="504000" y-from="736866" x-till="540000" y-till="747966"<br> destination-id="{$forward-id}" destination="{$forward-id}" destination-x="64800"<br> destination-y="727200"/><br> </xsl:if><br> <xsl:if test="$page-number > 1"><br> <xsl:variable name="back-id" select="concat($pagestr,$page-number - 1)"/><br> <xep:image src="cliser://localhost/F:/Desktop%20Files/CoolTools/DocNav/back.png"<br> type="image/png" x-from="72000" y-from="739350" scale-x="0.5" scale-y="0.5"<br> width="36000" height="15000"/><br> <xep:internal-link x-from="72000" y-from="736866" x-till="108000" y-till="747966"<br> destination-id="{$back-id}" destination="{$back-id}" destination-x="64800"<br> destination-y="727200"/><br> </xsl:if><br> </xep:page><br> </xsl:template><br> <xsl:template match="@* | *"><br> <xsl:copy><br> <xsl:apply-templates select="@* | *"/><br> </xsl:copy><br> </xsl:template><br><br></xsl:stylesheet><br><br><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>