JCO9
JCO9

Reputation: 990

Hyperlink to location within document DocX dll C#

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.

Upvotes: 1

Views: 827

Answers (1)

Thorarins
Thorarins

Reputation: 1904

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.

Upvotes: 0

Related Questions