Skip to main content
1-Visitor
February 11, 2014
Solved

How to know the last page of a title in a TOC?

  • February 11, 2014
  • 1 reply
  • 1881 views

Hi all,

In a TOC, is showed the first page where each title starts. I need to know the last page where the content of this title appears. Someone knows how can I do it?

Best answer by SimonTaylor

There isn't any information by default, but you could add some if you like.

Use something like

formatting.currentXMLNode.setUserString("lastPage", formatting.currentPage.pageNumber);

in the 'onExit' source for your title (better still in the onExit code of a property set associated with the title).

You can then use XPath in your ToC to retrieve that information using something like:

formatting.evaluateXPath('x3b2:get-userData("lastPage", self::refNode())');

Use that in the generated ToC elements somewhere...

setUserString() is a DOM method to add private info onto a node. The get-userData() XPath extension function is an XPath equivalent. self::refNode() is a custom location passed by nodes which are augmented onto a DOM when adding a TOC.

Simon

1 reply

rboneti1-VisitorAuthor
1-Visitor
February 11, 2014

In App, there's any information about this? (last page, or current page)

14-Alexandrite
February 11, 2014

There isn't any information by default, but you could add some if you like.

Use something like

formatting.currentXMLNode.setUserString("lastPage", formatting.currentPage.pageNumber);

in the 'onExit' source for your title (better still in the onExit code of a property set associated with the title).

You can then use XPath in your ToC to retrieve that information using something like:

formatting.evaluateXPath('x3b2:get-userData("lastPage", self::refNode())');

Use that in the generated ToC elements somewhere...

setUserString() is a DOM method to add private info onto a node. The get-userData() XPath extension function is an XPath equivalent. self::refNode() is a custom location passed by nodes which are augmented onto a DOM when adding a TOC.

Simon

rboneti1-VisitorAuthor
1-Visitor
February 11, 2014

Thanks for help Simon!

Using your help, I get the number of the last page, and the first too.

The first page, I got on the "onEnter" and the last page I got on the "onExit".

Now, I need to use this both informations together, to write a stream like this:

for(var i = firstPage;i<=lastPage;i++)

{

stream.write( "Intro ...." + i + "\n");

}

I can do it with xpath or something?