Create links in Aspose.Html


#1

Hi team,
i don’t know how to create a link (tag a with href) to an external Url within Aspose.Html for .Net. Something like:
My link
I could’nt find how to do it in the documentation.

I try tu create an HTMLAnchorElement but when a save my HTML file, the href was replaced by a local uri.

Update:
Sorry, I’ve seen that the problem is not the link, the problem is when a Save the HtmlDocument to a file. This function raplaces the link by a local address with the suffix “_files”.

Thanks in advance

2018-09-06_154545.jpeg (17.1 KB)


#2

@ppalomo

Thank you for contacting support.

We are looking into your requirements and will get back to you soon with our findings.


#3

@ppalomo

We would like to update you that you can create a link in HTML file by using below code snippet in your environment.

        HTMLDocument document = new HTMLDocument();
        HTMLAnchorElement a = (HTMLAnchorElement)document.CreateElement("a");
        a.Href = "https://www.aspose.com/";
        a.TextContent = "Aspose Website";
        document.Body.AppendChild(a);
        Console.WriteLine(document.DocumentElement.OuterHTML);
        document.Save(@"document.html");

Generated HTML file has also been attached for your kind reference. document.zip

We hope this will be helpful. Please feel free to contact us if you need any further assistance.