In the DocX library available at : https://github.com/WordDocX/DocX
It is possible to add some hyperlink but i haven't found a way to add internal link.
Does anyone know how to add a link to specific paragraph or to a bookmark ?
In the DocX library available at : https://github.com/WordDocX/DocX
It is possible to add some hyperlink but i haven't found a way to add internal link.
Does anyone know how to add a link to specific paragraph or to a bookmark ?
The way I've found is:
synthesisDocument.AddHyperlink("Link",new Uri("file:///path/to/doc/file.doc#MY_BOOKMARK"));
synthesisDocument.Paragraphs[0].InsertHyperlink(h)
That way resolve your problem, but only in doc format, when you export to PDF it doesn't work. I hope it helps
As mentioned #BookMark does work if the Uri is created with the UriKind.Relative flag:
var uri = new Uri("#" + BookMark,UriKind.Relative);
var hyperLink = doc.AddHyperlink(textToDisplay, uri );
Now to use the hyperlink on a paragraph, p:
p.InsertHyperlink(hyperLink,indexToInsertAt);
I achieved exactly the result I wanted using this in both .docx and .pdf
Hope it works for you,
Nick