Author Topic: DocumentGenerator.InsertHyperlink() #BOOKMARKNAME  (Read 216 times)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1775
  • Karma: +122/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
DocumentGenerator.InsertHyperlink() #BOOKMARKNAME
« on: June 11, 2020, 12:59:01 am »
Hey hackers,


DocumentGenerator.InsertHyperlink(), right?
"Inserts a hyperlink at the current location. If you use a URL with the  #BOOKMARKNAME syntax, the hyperlink will link to another part of the document."

I want to link to another part of the document.
My question is: how?
How, using DocumentGenerator, do I create the target for this hyperlink?
Not the link itself. The target. The place in the document that I want the link to point to. How do I create that?

TIA,


/Uffe
« Last Edit: June 11, 2020, 01:04:07 am by Uffe »
My theories are always correct, just apply them to the right reality.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 7411
  • Karma: +176/-120
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: DocumentGenerator.InsertHyperlink() #BOOKMARKNAME
« Reply #1 on: June 11, 2020, 08:38:08 am »
Hey Uffe,
Early in the last century, there was a famous English cooking author (Mrs Beaton) whose recipe for Rabbit pie is reputed (since disproved) to have started:
Rabbit Pie
1. First, catch your rabbit.

If I understand you correctly you're asking how to catch the rabbit, yes?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Uffe

  • EA Practitioner
  • ***
  • Posts: 1775
  • Karma: +122/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: DocumentGenerator.InsertHyperlink() #BOOKMARKNAME
« Reply #2 on: June 12, 2020, 05:54:07 pm »
If I understand you correctly you're asking how to catch the rabbit, yes?

Yes. Although I prefer Sagan's version of the pie recipe. :)

So how do I reference that "other part of the document"? Or rather, how do I make that other part of the document referable?


/U
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10418
  • Karma: +343/-30
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: DocumentGenerator.InsertHyperlink() #BOOKMARKNAME
« Reply #3 on: June 12, 2020, 06:14:42 pm »
You can add bookmarks in a template, but I've only ever used those to conditionally hide stuff, never as the target of a hyperlink.

It might be a place to start looking though

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1775
  • Karma: +122/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: DocumentGenerator.InsertHyperlink() #BOOKMARKNAME
« Reply #4 on: June 13, 2020, 01:25:37 am »
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
My theories are always correct, just apply them to the right reality.