1
votes

I am currently generating Word documents with the Novacode DocX dll and C# from an asp.Net website, what I try to achieve is to create hyperlinks inside the document that point to elements within it (Click a paragraph and go to first page for example), what I have achieved so far is to create hyperlinks pointing outside the document this way:

Hyperlink lnk = document.AddHyperlink("Google", new Uri("http://www.google.com"));

// Create Paragraph and set the link
Paragraph par = document.InsertParagraph();
par.Append("Google");
par.AppendHyperlink(lnk);

After searching in Internet for a while and playing with the hyperlink class I cannot find the way do achieve this, does someone know how to do it?

Many thanks in advance.

1
This seems currently not supported. Only external links are supported. - Dirk Vollmar
You could almost certainly do this with the OpenXML SDK. DocX looks really limited. - Chris
After 3 days looking for a solution I found nothing, just some people with the same question but no answer, although I am not 100% sure I will asume it is not supported by DocX and try with OpenXML SDK as suggested by @Chris, many thanks. - JCO9

1 Answers

0
votes

you have to use relative links , like href="#_top" for top of the document, and add bookmarks for other places in the document. But i'm not sure if docX handles bookmarks.