Free Support Forum - aspose.com

Problem in displaying Link In PDF(Urgent)

Hi

I am showing link on PDF. It is working perfectly fine but for link

http://www.marketwatch.com/story/exterra-announces-drilling-plans-for-their-barnett-shale-assets-2010-03-10?reflink=MW_news_stmp

throw an error index out of the bound array.

My Code -->

string NewsLink = Convert.ToString(_oDSet.Tables[0].Rows[i][4]);if (IsNewsSource && !string.IsNullOrEmpty(Convert.ToString(NewsLink)))

{

Aspose.Pdf.Row _row6 = tbl1.Rows.Add();

Aspose.Pdf.Text tNewsLinkHeader = new Aspose.Pdf.Text(NewsLink , pdfStyle.StyleForNewsLink());

tNewsLinkHeader.IsHtmlTagSupported = true;tNewsLinkHeader.IsSpaced =

true;

tNewsLinkHeader.Margin.Top = 0;

tNewsLinkHeader.Margin.Bottom = 0;

Aspose.Pdf.Cell _cell62 = _row6.Cells.Add(); _cell62.Alignment = Aspose.Pdf.AlignmentType.Left;

//_cell62.Padding = mrg;

_cell62.Paragraphs.Add(tNewsLinkHeader);

}


This message was posted using Aspose.Live 2 Forum

Hello Gaurav,

I have tested the scenario using the following code snippet and I am unable to notice any problem. As per my understanding, the issue is not related to hyperlink. Can you please share the complete code snippet, so that we can test the scenario once again.

[C#]

// Instantiate an object PDF class
Pdf pdf = new Pdf();
// add the section to PDF document sections collection
Aspose.Pdf.Section section = pdf.Sections.Add();

Aspose.Pdf.Table tbl1 = new Aspose.Pdf.Table();
section.Paragraphs.Add(tbl1);
Aspose.Pdf.Row _row6 = tbl1.Rows.Add();
Aspose.Pdf.Text tNewsLinkHeader = new Aspose.Pdf.Text();

//Add a text segment in the text paragraph
Segment segment2 = tNewsLinkHeader.Segments.Add("this is a web link");
//Assign a new instance of hyperlink to hyperlink property of segment
segment2.Hyperlink = new Aspose.Pdf.Hyperlink();
//Set the link type of the text segment to Web
segment2.Hyperlink.LinkType = HyperlinkType.Web;
//Set the URL of the web location to create a web link for the segment
segment2.Hyperlink.Url = "http://www.marketwatch.com/story/exterra-announces-drilling-plans-for-their-barnett-shale-assets-2010-03-10?reflink=MW_news_stmp";

Aspose.Pdf.Cell _cell62 = _row6.Cells.Add();
_cell62.Alignment = Aspose.Pdf.AlignmentType.Left;
_cell62.Paragraphs.Add(tNewsLinkHeader);

//Save the pdf document
pdf.Save("D:/pdftest/inlinetest.pdf");

The resultant PDF that I have generated using the above code is also in attachment, please take a look.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We apologize for your inconvenience.