xsl-list
[Top] [All Lists]

Re: [xsl] [xsl-fo] Do a foreach for the number of pages

2011-12-19 12:04:26
At 2011-12-19 11:58 -0600, Colin DeClue wrote:
So, I was wondering if it was possible to do a foreach for the number
of pages in the document, minus a number provided in the xml.
Basically, I have a flow that I want to end on the last page, rather
than start on the first page. If I could add page breaks for how many
pages the document is minus how many pages the flow is going to take
up, I could easily do this. It does, however, seem like something that
could easily be impossible, since the for-each could impact the number
of pages, and what would the processor do then?

In the XSL-FO specification there is no feedback from the XSL-FO processor back to the transformation you are using to create your XSL-FO instance (typically XSLT but it doesn't have to be). Therefore, you can never know at transformation time how many pages the formatting will take.

You can consider what vendors may offer with their specific products. For example, the RenderX tool has an intermediate format that you can massage between the formatting and the rendering.

Another possibility is to inspect the PDF you create and do a second pass with your input as I do with the "back of the book index" facility I posted for XSLT 1.0 users as a free developer resource on my web site. Using a tool like iText you can count the number of pages in the PDF file and then re-run your transformation with that knowledge.

I hope this helps.

. . . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/uoui9h
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--