Free Support Forum - aspose.com

How to add html tags in aspose.pdf.generator.cell

Hi Aspose Team,

This post is related to Aspose.pdf section.

I am just wondering if we have something like

IsHtmlTagSupported = true; setter property to use in below case

row.Cells.Add("

INITIAL GIS FORECAST (ESTIMATED) FOR BLACKROCK SECURITY
ASSESSMENT


 


 










Period



Description


");

row.Cells[1].BackgroundColor = new Aspose.Pdf.Generator.Color("#D8D8D8");

row.Cells[1].DefaultCellTextInfo = new TextInfo

{

IsTrueTypeFontBold = true,

FontSize = 9

};

I have one aspose.table where in cell html tags are going to come from Database.

Thanks

Amit Burnwal

as we can set IsHtmlTagSupported property for Text object, can we have something for object DefaultCellTextInfo. I need to add html tag in aspose.table cell

Hi Amit,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.Pdf.

Please see the following sample code regarding how to add HTML tags in a Table Cell using Aspose.Pdf for .NET.

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();

Aspose.Pdf.Generator.Table tblDocData = new Aspose.Pdf.Generator.Table();

tblDocData.DefaultCellTextInfo.FontName = "Arial";

tblDocData.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);

tblDocData.ColumnWidths = ("150 250");

DataTable dtDocuments = new DataTable();

dtDocuments.Columns.Add("1", System.Type.GetType("System.String"));

dtDocuments.Columns.Add("2", System.Type.GetType("System.String"));

for (int row = 0; row <= 10; row++)

{

DataRow dr = dtDocuments.NewRow();

dr[0] = "Status Testing " + row.ToString();

dr[1] = "Document " + row.ToString();

dtDocuments.Rows.Add(dr);

}

dtDocuments.AcceptChanges();

Aspose.Pdf.Generator.Row rDocHeader = tblDocData.Rows.Add();

Aspose.Pdf.Generator.Cell c1header = rDocHeader.Cells.Add("Status");

Aspose.Pdf.Generator.Cell c2header = rDocHeader.Cells.Add("Document Name");

int i;

for (i = 0; i <= dtDocuments.Rows.Count - 1; i++)

{

Aspose.Pdf.Generator.Row r11 = tblDocData.Rows.Add();

int j;

for (j = 0; j <= dtDocuments.Columns.Count - 1; j++)

{

Aspose.Pdf.Generator.Cell clbl = r11.Cells.Add();

string s = (dtDocuments.Rows[i][j]).ToString();

Aspose.Pdf.Generator.Text text1 = new Text(s);

text1.IsHtmlTagSupported = true;

clbl.Paragraphs.Add(text1);

}

}

sec1.Paragraphs.Add(tblDocData);

pdf.Save(@"d:\ap data\Table_HTML_Formating.pdf");

Please feel free to contact support in case you need any further assistance.

Thank You & Best Regards,