Hey guys,
OK, I get how it works now. There are two parts, obviously, creating the bookmark and creating the link. Unfortunately, only the second of these is supported in the API.
Creating the hyperlink is easy as pie. Just call DocumentGenerator.InsertHyperlink("Click here", "#MySweetBM") where MySweetBM is the name of the bookmark. Nothing else there, just the hash and the bookmark name.
Creating the bookmark, well that's a different matter.
You can create custom bookmarks in the templates. Since bookmarks are simply referred to by name, if you add a bookmark to some part of a template that gets repeated, bookmarks from latter applications of the template will overwrite earlier ones. So in the final document, only the text resulting from the last application of the template will contain the bookmark.
There appears to be no way to generate bookmark names based on the package, element, etc that's being processed by the template. Interestingly, each diagram image gets a bookmark BKM_GUIDish, where GUIDish is the diagram GUID, minus curly braces and with dashes replaced by underscores. Presumably, if the same diagram is included more than once the bookmark will mark the last occurrence.
And DocumentGenerator of course has no method for creating a bookmark. So while you can InsertText() using the API, and you can InsertHyperlink() using the API, and InsertHyperlink() can target a bookmark, you can't create bookmarks in the API which makes the whole thing seem kinda pointless.
/Uffe