I send the following string
string text = <img alt=\"\" src=\"http://localhost:6666/content/userfiles/admin/images/q4.png\" /><br/>
to:
public static Paragraph CreateSimpleHtmlParagraph (String text)
{
string fontpath = System.Web.HttpContext.Current.Server.MapPath("~/Content/");
BaseFont bf = BaseFont.CreateFont(fontpath + "ARIALUNI.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
var f = new Font(bf, 10, Font.NORMAL);
var p = new Paragraph
{
Alignment = Element.ALIGN_LEFT,
Font = f
};
var styles = new StyleSheet();
styles.LoadTagStyle(HtmlTags.SPAN, HtmlTags.FONTSIZE, "10");
styles.LoadTagStyle(HtmlTags.BODY, HtmlTags.ENCODING, BaseFont.IDENTITY_H);
using (var sr = new StringReader(text))
{
var elements = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(sr, styles);
foreach (var e in elements)
{
p.Add(e);
}
}
return p;
}
using:
document.Add(CreateSimpleHtmlParagraph("<span style='font-size:10;'>" + "<b><u>" +
"Notes" + "</u></b>" + ": " + "<br/><br/>" + text + "</span>"));
to generate PDF using itextsharp, It works very well except the image is too large! Is there a way to check if the string includes width and height and if not add the to scale the image?