Dear All,
I am generating PDF on Button Click. The Pdf includes filenames with hyperlink to the server folder. The file names are retrieved base on GridView row column. The method is fine if there is only one file in the row column. In case of several files in a row column, the hyperlink get concatenated in one link. as shown below
http://i68.tinypic.com/2hh3r49.jpg
I am using the following methods:
Chunk imdb = new Chunk("\n" + GetDocumentsExportFileName(Convert.ToInt32(dr["BruddLosID"]), false), FontFactory.GetFont("Arial", 7, Font.NORMAL, Color.BLUE));
imdb.SetAnchor(new Uri(GetDocumentsExport("BruddLosPerson", Convert.ToInt32(dr["BruddLosID"]), true, false, false)));
phrase = new Paragraph("Click containing links ");
phrase.Add(imdb);
cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
table.AddCell(cell);
public string GetDocumentsExport(string folderName, int id, bool isEditable = true, bool isDeletable = false, bool isAdmin = false)
{
string constr = ConfigurationManager.ConnectionStrings["DataString1"].ConnectionString;
string documents = "";
SqlConnection sqlConn = new SqlConnection(constr);
sqlConn.Open();
string sqlQuery = "Select * from brudd_PostedFile where bruddid = " + id + " And IsAdmin = '" + isAdmin + "'";
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.Connection = sqlConn;
sqlCmd.CommandType = CommandType.Text;
sqlCmd.CommandText = sqlQuery;
SqlDataAdapter sqlAdp = new SqlDataAdapter(sqlCmd);
DataSet ds = new DataSet();
sqlAdp.Fill(ds);
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
// string FilePath = "/Upload/" + folderName + "/" + Convert.ToString(ds.Tables[0].Rows[i]["FileName"]);
if (isEditable)
{
if (!isDeletable) // = TRUE VALUE
{
if (isAdmin) // NOT ADMIN
{
documents += GetAbsoluteUrl("~/Upload/BruddLosAdmin/") + Convert.ToString(ds.Tables[0].Rows[i]["FileName"]) + "\n";
}
else if (!isAdmin) // ADMIN
{
documents += GetAbsoluteUrl("~/Upload/BruddLosPerson/") + Convert.ToString(ds.Tables[0].Rows[i]["FileName"]) + "\n";
}
}
}
else
documents += Convert.ToString(ds.Tables[0].Rows[i]["FileName"]);
}
sqlConn.Close();
return documents;
}
private string GetAbsoluteUrl(string relativeUrl)
{
relativeUrl = relativeUrl.Replace("~/", string.Empty);
string[] splits = Request.Url.AbsoluteUri.Split('/');
if (splits.Length >= 2)
{
string url = splits[0] + "//";
for (int i = 2; i < splits.Length - 1; i++)
{
url += splits[i];
url += "/";
}
return url + relativeUrl;
}
return relativeUrl;
}
How to solve this issue?
Many thanks