Altova Mailing List Archives


Re: [xsl] Strategies for complex page numbering in PDF's.

From: "G. Ken Holman" <gkholman@----------------.--->
To: xsl-list@-----.------------.---
Date: 2/1/2011 11:18:00 PM
At 2011-02-01 08:38 -0700, Dan Haley wrote:
>I have a question about custom page numbering ("point pages") when 
>creating a PDF. I'm using XSLT to create XSL-FO from an XML 
>instance. My XSLT processor is Saxon 9 and my XSL-FO processor is 
>RenderX (4.18).
>
>What I need to do is be able to change the page numbering once it 
>reaches a certain point. (The page number that is in the footer 
>(static-content).)
>
>Lets say I have a book that has multiple chapters in it. Each one of 
>these chapters has a chapter number. This chapter number is what the 
>page numbering is based on.
>
>For example, if the chapter number is 2000, the first page of the 
>chapter would be 2001.
>
>This is fine up until the 998'th page (the chapter has to end on an 
>even page). For example, if chapter 2000 had 1,002 pages the page 
>numbering of the last 6 pages would be:
>
>2997, 2998, 2999, 3000, 3001, 3002
>
>This is incorrect since there might be a chapter 3000.
>
>What I need to do is be able to change the page numbering after the 
>998'th page. Using my chapter 2000 with 1,002 pages example, the 
>numbering should be:
>
>2997, 2998, 2998.1, 2998.2, 2998.3, 2998.4.

Using standard XSL-FO, you won't know when the flow hits page 2999 to 
know to start a new page sequence with a new page number and your 
fixed footer.  And, the act of using the new page sequence to get the 
new restarting page number will trigger a page break and content at 
the start.  But that is moot since you don't know when to use the 
page sequence.

>This is what I'm doing now:
>
>     *    I'm using <fo:page-number> in my fo:static-content.
>     *    I'm setting the starting page number (chapter number + 1) 
> using the initial-page-number attribute in the fo:page-sequence element.
>
>If I have to I can manipulate the intermediate file that XEP 
>(RenderX) creates,

This was my first thought.

>but I think it could get messy and I'm not sure how reliable that would be.

I wouldn't be too worried.  I think it is pretty 
deterministic.  Though I confess I know nothing of the RenderX 
intermediate format and so my scheme may not work for you.

My thoughts are related to the extensibility of XSL-FO with foreign 
namespaces.  In my UBL stylesheet work I seed XSL-FO instances with 
my LiterateXSLT or ResultXSLT namespaces of elements and attributes 
with XPath addresses.  Any conformant XSL-FO processor simply ignores 
these foreign properties.  I can run my XSL-FO instance through a 
processor in order to preview the formatted output I've created.  I 
then run those XSL-FO instances through XSLT and I synthesize the 
XSLT stylesheet that creates those instances from production 
data.  It is all for free download from my web site's Free Resources section.

So, the concept of leaving signals in an XML document using a foreign 
namespace is used in a number of applications.  Hopefully this is 
available in the RenderX intermediate file format.

>Also, updating the Table of Contents would probably end up being a 
>nightmare. (The intermediate file produced by XEP is the 
>post-processed XSL-FO; it has the page numbers already generated.)

Perfect.  Then all you have to do is seed the XSL-FO with non-XSL-FO 
custom information with your bread crumbs, hopefully having this end 
up in the intermediate format (I don't know if it does or not).  This 
will tell you when you are running the intermediate format file 
through XSLT which page numbers in the TOC are in which chapter, and 
that tells you when page 3017 is page 2998.19 of chapter 2000 or page 
3017 of chapter 3000.  And you can do this for all page number citations.

So, after RenderX has produced the intermediate file, which I believe 
is all in XML, you can walk through that and massage page numbers 
based on the bread crumbs you leave.  Then, after post processing, 
feed that instance on for rendering.

>Does anyone have any suggestions on strategies I can use to 
>accomplish this? I thought I read somewhere that I could use a 
>maximum-repeats attribute in the page-sequence-master element (like 
>maximum-repeats="998") and then use a different master page, but I 
>have no idea how to do that.

I don't think that helps you.  The *only* time initial-page-number="" 
is set is at the beginning of a page sequence.  You can't, in 
standard XSL-FO, do any manipulation or inspection of the page 
number.  And you can't, in XSLT, know when your content needs to 
trigger that new page sequence with the new "dot" page numbers.

I hope this helps.

. . . . . . . . . . . . Ken

--
Contact us for world-wide XML consulting & instructor-led training
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
G. Ken Holman                 mailto:gkholman@C...
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.