My code is generating a PDF and I am encountering an issue with a black bordered cell appearing behind the image in this specific line:
sb.AppendLine("<tr><td>" + "~/images/Products/" + imageName + "</td><td>~/images/spacer.gif</td></tr>");
I have attempted to set the border to 0 on the table, but I am receiving an error of ") expected", or the HTML structure breaks.
How can I prevent the border from displaying around this particular cell?
The relevant sections of my code are as follows:
//add images
str = new StringBuilder();
str.Append("<table>");
if (HasRelatedImages(ContentId, ref str))
{
obj = new List<FieldIdentifier>();
obj.Add(new FieldIdentifier() { LabelName = "Images", Value = "" });
index = index + 1;
rows.Add(index, obj);
obj = new List<FieldIdentifier>();
obj.Add(new FieldIdentifier() { LabelName = "NewTable_Data", Value = str.Append("</table>").ToString() });
index = index + 1;
rows.Add(index, obj);
}
//end images
and
private Boolean HasRelatedImages(long productId, ref StringBuilder sb)
{
var imagemetadata = new List<ImageMetadata>();
int i = 0;
try
{
Database db = DatabaseFactory.CreateDatabase("Site.DbConnection");
DbCommand dbCommand = db.GetStoredProcCommand("[spSelectImages]");
db.AddInParameter(dbCommand, "@ContentID", DbType.Int64, productId);
IDataReader dr = db.ExecuteReader(dbCommand);
while (dr.Read())
{
string imageName = GetNullableDBStringValue(dr["ImageName"]);
string altText = GetNullableDBStringValue(dr["ALTText"]);
altText = HttpUtility.HtmlEncode(altText);
if (!string.IsNullOrEmpty(imageName) && System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/images/Products/" + imageName)))
{
i++;
sb.AppendLine("<tr><td>" + i.ToString() + "</td><td>" + (string.IsNullOrEmpty(altText) ? " " : altText) + "</td></tr>");
sb.AppendLine("<tr><td>" + "~/images/Products/" + imageName + "</td><td>~/images/spacer.gif</td></tr>");
}
}
dr.Close();
}
catch
{
}
if (i > 0) return true;
return false;
}