[xep-support] Re: CoolTool; Document Navigation Tool

Mark Giffin mgiffin at earthlink.net
Sun Mar 8 10:47:27 PDT 2015


Are "XEP Intermediate Format" and "XEPOUT" the same thing? Not defined 
in text below.

Thanks,
Mark

On 2/26/2015 4:46 PM, Kevin Brown wrote:
>
> Oh, and I would note that you would need to change this at least to 
> link to your own images.
>
> Don’t try to just run this as is as you would insert a link to a 
> non-existing image into the XEPOUT which is a fatal error and XEP 
> would abort.
>
> It never expects that as XEPOUT is normally created by XEP and the 
> images exist or point to the “not-found” image.
>
> Mine in this XSL are pointing to:
>
> src="cliser://localhost/F:/Desktop%20Files/CoolTools/DocNav/forward.png"
>
> Which is XEPWin-speak (the cliser: protocol) pointing to an image file 
> at “F:\Desktop Files\CoolTools\DocNav\forward.png”.
>
> But of course, you would have your own images or text, colors. You 
> could even insert them into the original document without any link and 
> then grab their coordinates to create the link.
>
> Kevin Brown
>
> RenderX
>
> *From:* Xep-support [mailto:xep-support-bounces at renderx.com] *On 
> Behalf Of *Kevin Brown
> *Sent:* Thursday, February 26, 2015 4:28 PM
> *To:* 'RenderX Community Support List'
> *Subject:* [xep-support] CoolTool; Document Navigation Tool
>
> Recently someone asked a great question, and great questions always 
> get us thinking.
>
> They wanted to implement document navigation widgets like “Next Page” 
> and “Previous Page”.
>
> 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.
>
> 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.
>
> But they do not have the PDF Acroforms add-on to RenderX.
>
> Not that I like **not** selling someone something, I thought about it 
> for a minute.
>
> 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.
>
> Maybe throwing markers throughput the document and some complicated 
> scheme.
>
> But why try to create something in XSL FO (which is not page aware)?
>
> 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.
>
> 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?
>
> Well that is pretty easy, something like this:
>
> <xep:target x="0" y="792000" id="docnav-1" name="docnav-1"/>
> <xep:target x="0" y="792000" id="rx:last at docnav-1" 
> name="rx:last at docnav-1"/>
>
> The “x” and “y” coordinates contain the upper left corner of the anchor.
>
> The id and name are used internally to make a table of all the anchors.
>
> Now, what about a link that goes to some internal destination?
>
> Again, easy, something like this:
>
> <xep:internal-link x-from="72000" y-from="736866" x-till="108000" 
> y-till="747966"
>             destination-id="docnav-1" destination="docnav-1" 
> destination-x="64800"
>             destination-y="727200"/>
>
> The x-from, y-from, x-till, y-till are the bounding box of the 
> clickable area.
>
> The destination-id is the id to go look for in the document and display.
>
> I am not going to go into some of the others, they are actually not 
> that important.
>
> 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.
>
> Given that and a little knowledge of XEPOUT, we have everything we 
> need to build something like a “page turner”.
>
> 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).
>
> Any questions? Write us! Or discuss here.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version="1.0"
>     xmlns:xep="http://www.renderx.com/XEP/xep">
>     <!-- 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 -->
>     <xsl:variable name="pagestr" select="'docnav-'"/>
>     <!-- Get the total number of pages in the document -->
>     <xsl:variable name="totpages" select="count(//xep:page)"/>
>     <xsl:template match="xep:page">
>         <xep:page width="{@width}" height="{@height}" 
> page-number="{@page-number}"
>             page-id="{@page-id}">
>             <!-- Add a destination on each page right after the 
> xep:page -->
>             <xsl:variable name="page-number" 
> select="count(preceding-sibling::xep:page) + 1"/>
>             <xsl:variable name="page-numid" 
> select="concat($pagestr,$page-number)"/>
>             <xsl:variable name="page-height" select="@height"/>
>             <xep:target x="0" y="{$page-height}" id="{$page-numid}" 
> name="{$page-numid}"/>
>             <xep:target x="0" y="{$page-height}" 
> id="rx:last@{$page-numid}"
>                 name="rx:last@{$page-numid}"/>
>             <!-- Output everything on the page -->
>             <xsl:apply-templates/>
>             <!-- Then add the navigation buttons with logic to not add 
> back on page 1 nor forward on the last page -->
>             <xsl:if test="$page-number < $totpages">
>                 <xsl:variable name="forward-id" 
> select="concat($pagestr,$page-number + 1)"/>
>                 <xep:image 
> src="cliser://localhost/F:/Desktop%20Files/CoolTools/DocNav/forward.png"
>                     type="image/png" x-from="504000" y-from="739350" 
> scale-x="0.5" scale-y="0.5"
>                     width="36000" height="15000"/>
>                 <xep:internal-link x-from="504000" y-from="736866" 
> x-till="540000" y-till="747966"
>                     destination-id="{$forward-id}" 
> destination="{$forward-id}" destination-x="64800"
>                     destination-y="727200"/>
>             </xsl:if>
>             <xsl:if test="$page-number > 1">
>                 <xsl:variable name="back-id" 
> select="concat($pagestr,$page-number - 1)"/>
>                 <xep:image 
> src="cliser://localhost/F:/Desktop%20Files/CoolTools/DocNav/back.png"
>                     type="image/png" x-from="72000" y-from="739350" 
> scale-x="0.5" scale-y="0.5"
>                     width="36000" height="15000"/>
>                 <xep:internal-link x-from="72000" y-from="736866" 
> x-till="108000" y-till="747966"
>                     destination-id="{$back-id}" 
> destination="{$back-id}" destination-x="64800"
>                     destination-y="727200"/>
>             </xsl:if>
>         </xep:page>
>     </xsl:template>
>     <xsl:template match="@* | *">
>         <xsl:copy>
>             <xsl:apply-templates select="@* | *"/>
>         </xsl:copy>
>     </xsl:template>
>
> </xsl:stylesheet>
>
>
>
> _______________________________________________
> (*) To unsubscribe, please visit http://lists.renderx.com/mailman/options/xep-support
> (*) By using the Service, you expressly agree to these Terms of Service http://w
> ww.renderx.com/terms-of-service.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.renderx.com/pipermail/xep-support/attachments/20150308/d3d5997b/attachment.html>


More information about the Xep-support mailing list