Create dynamic bookmarks

Top Previous Topic Next Topic  Print this topic

Synopsis:

 

Sometimes it is useful to have list of access points within the document(bookmarks). How do I create bookmarks for dynamic data?

 

Answer:

 

This tutorial shows how to create a dynamic bookmark.

 

We'll assume you're already working with a new document and having already attached the cdcatalog.xml sample as data source.

We start with a repeating section of all CDs from the catalog. Each item in the repeating section contains a page break to better illustrate the functionality:

 

bookmark_tut1

 

Then set an id value to the block-repeat element using the bottom Navigation Bar:

 

Right click on block-repeat and choose Properties. The Properties pane will appear.
In the Properties pane, find the Object section and find the ID value. Write catalog for the ID value.

 

Now create the dynamic bookmark:

 

Open the Bookmarks dialog bar by checking Bookmarks in the View ribbon tab.
Click the Add Bookmark button to add a new bookmark. The Bookmark dialog will appear.
Click the More >> button to display the Dynamic Features.
Click on the arrow associated with the Repeat box. The Edit Expression dialog will appear. Select /ns:catalog/ns:cd as the XPath. This will set the bookmark's context to /ns:catalog/ns:cd. We do this so that the bookmark's context matches that of the repeating block's. This is mandatory for the dynamic bookmark to work.
In the Target Object box, choose xfd:repeating-block (catalog).
In the Label box, click "..." to bring up the Property Value dialog.
Choose Dynamic value from input XML and click the arrow at the right of the textbox. The Edit Expression dialog will appear. Note that the context is now set to /ns:catalog/ns:cd because of the value we filled in the Repeat box. Double click on title to select the title of the current CD. Click OK to close the Edit Expression dialog, then OK to close the Property Value dialog.

 

If all the steps have been followed correctly, the fields in the Bookmark dialog should be filled like this:

 

bookmark_tut3

 

Click OK to create the bookmark.

 

The bookmark should appear as Dynamic Bookmark in the tree, and the target id should be catalog. Go to the Home ribbon tab and click Preview as PDF to preview the document.

 

The PDF should have a bookmark for each dish. Because we have added a page break in the repeating block, each repeating block will be on a new page, and clicking the bookmark will navigate to that page:

 

bookmark_tut4