[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: Strategies for complex page numbering in PDF's.
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 01 Feb 2011 18:17:47 -0500
Re:  Strategies for complex page numbering in PDF's.
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@xxxxxxxxxxxxxxxxxxxx
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.