cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

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

rboneti
7-Bedrock

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

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?

ACCEPTED SOLUTION

Accepted Solutions
SimonTaylor
13-Aquamarine
(To:rboneti)

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

View solution in original post

5 REPLIES 5
rboneti
7-Bedrock
(To:rboneti)

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

SimonTaylor
13-Aquamarine
(To:rboneti)

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

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?

SimonTaylor
13-Aquamarine
(To:rboneti)

Hi - I am unclear what you're asking for. Your original post asked for the last page number...

Simon

It was another question about the subject, but I already found a solution.

Announcements

Top Tags