Forum How do I...?

How to generate a table of contents using pdf bookmarks?

ricky.how
We are trying to generate a table of contents using the following rule

/* Style the table of contents */
div.tableofcontents ul a:after {
content: leader('.') target-counter(attr(href), page);

Unfortunately the page numbers are all 0 because the hyperlinks are to a location outside of the generated document.

The pdf bookmarks are fine however. Therefore I am wondering if it is possible to modify the rule to use the pdf bookmarks?

This would be helpful to other Deki developers using the makebook template btw.
mikeday
If the links point to another document that will not be within the generated PDF, do you need page numbers at all? I'm not quite understanding the situation. :)
ricky.how
We have a single sourcing architecture where
- topics are stored in a repository
- outlines of publications are stored in a project space
- generated documents are stored in a library space.

Deki has a content reuse mechanism similar to DITA conrefs, called page transclusion (i.e. wiki.page). By specifying the name and path of content anywhere in the wiki, it can be dynamically incorporated into a page.

Change a topic and all the publications that reuse it are updated automatically. Change the outline, and the publication is reorganized.
Note: It is to this outline that the table of contents is linked - not to the content in the generated document.

The following line of code can generate a document of any length by iterating through an outline and transcluding content from the repository.
{{template.UserMakeBook(outlinepath.."Introduction") }}

Here is a version of makebook close to what we are using, however we have modified it to insert html tags as required for the css rules to paginate etc. http://wiki.developer.mindtouch.com/DekiScript/FAQ/How_do_I..._Output_a_group_of_wiki_pages_using_DekiScript%3f
mikeday
Okay, I think I get it now. The problem is that when the HTML is produced by Deki and sent to Prince, the links are not being correctly resolved; the code must look something like this:
<!-- table of contents -->
<a href="wrong_intro.html">Introduction</a>
...
<!-- document body -->
<h1 id="intro">Introduction</h1>

In this example the link is not correctly pointing to the local ID in the current generated document, so the link doesn't work and any generated cross-reference will be stuck at zero.

However, Prince is still able to generate a valid PDF outline or bookmark from the <h1> heading, as this is done independently of any other links in the document.

Solving this issue is going to require capturing the actual HTML that Deki is generating and feeding to Prince, so that we can see what the links are and how they need to be adjusted to make them work.