Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Hyperlink in HtmlFragment Text

$
0
0
Hi,

I would like to know, how to enable hyperlinks in a HtmlFragment Text. The scenario is as below

I am having a HTML content coming from a different source, I have to display the content as it is, I am displaying the Same HTML content in PDF using HtmlFragment in a document. The hyperlinks in the text are getting enabled. Please suggest, how to proceed further. Attached is the output file generated from ASPOSE. Code for the same is as below:

            var dataDir = AppDomain.CurrentDomain.BaseDirectory;
            var lic = new Aspose.Pdf.License();
            lic.SetLicense("Aspose.Pdf.lic");

            Document doc = new Document();
            var page = doc.Pages.Add();
            TextStamp textStamp = new TextStamp("Hello word");


                      HtmlFragment title1 = new HtmlFragment("Hello World, this is a link to go to<a href='www.google.com'>Google</a> Click here");

            title1.HtmlLoadOptionsOfInstance = new HtmlLoadOptions();
            page.Paragraphs.Add(title1);
            //title1.IsInNewPage = true;
            // Add HTML Fragment to paragraphs collection of page
            textStamp.TopMargin = 10;
            textStamp.HorizontalAlignment = HorizontalAlignment.Center;
            textStamp.VerticalAlignment = VerticalAlignment.Top;

            string s3 = "<h3 style='font-family:Verdana;font-size:larger;font-size:20px'>Raj</h3><br/> <Ul><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul>";

            HtmlFragment title2 = new HtmlFragment(s3);
            page.Paragraphs.Add(title2);

            doc.Save(dataDir + "abc.pdf");
            Document doc1 = new Document(dataDir + "abc.pdf");
            //Add header on all pages
            foreach (Page tpage in doc.Pages)
            {
                tpage.AddStamp(textStamp);
            }
            doc.Save(dataDir + "abc.pdf");


Regards,
Raj.

Viewing all articles
Browse latest Browse all 3131

Trending Articles