Hi comunidadmexi...,
You need to use the IBlockElement class SetProperty Property.
Refer below example.
string filename;
string html;
string dest;
Paragraph contents;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[]
{
new DataColumn("sID"),
new DataColumn("contents")
});
dt.Rows.Add(1, "<h3 style=color:#0000ff;><strong>Section 1</strong></h3>");
dt.Rows.Add(2, "<h4><strong>- Alert</strong></h4>");
filename = @"C:\Users\developer4\Desktop\Management_" + Guid.NewGuid() + ".pdf";
PdfWriter writer = new PdfWriter(filename);
PdfDocument pdf = new PdfDocument(writer);
Document document = new Document(pdf);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
List<IElement> lst = HtmlConverter.ConvertToElements(dt.Rows[i]["contents"].ToString()).ToList();
for (int j = 0; j < lst.Count; j++)
{
IBlockElement element = (IBlockElement)lst[j];
element.SetProperty(Property.LEADING, new Leading(Leading.MULTIPLIED, -1f));
document.Add(element);
}
}
dest = filename.ToString();
}
else
{
Console.WriteLine("No rows found.");
}
document.Close();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + dest);
Response.TransmitFile(dest);
Response.End();
}
}