Itextshart Font Size Too Small: 0 Error
I am trying to create a pdf file from the html content. Yet, there is a matter that prevent it this is Font size too small: 0 error when ı click the button in hw.Parse(new
Solution 1:
iText[Sharp] HTMLWorker
doesn't support CSS absolute-size values, which at least one line in your HTML is using, and causing the exception:
<span id='Label3' style='color:Red;font-size:xx-Large;font-weight:bold;'>ECN NO:</span> <span id='Label48' style='font-size:x-Large;'>aaa</span>
Remove the styles like font-size:xx-Large
and you should be fine.
If you're open to using the new iText[Sharp] XML/HTML parsers, you can use CSS absolute-size values - something like this works with XML Worker version 1.1.3.0:
StringReader stringReader = new StringReader(@"
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head><title></title></head>
<body>
<span id='Label3' style='color:Red;font-size:XX-Large;font-weight:bold;'>ECN NO:</span>
<span id='Label48' style='font-size:X-Large;'>aaa</span>
</body></html>
");
using (Document document = new Document()) {
PdfWriter writer = PdfWriter.GetInstance(document, STREAM);
document.Open();
XMLWorkerHelper.GetInstance().ParseXHtml(
writer, document, stringReader
);
}
Solution 2:
In may case I used style="font-size:large;" which caused error. Changing it to style="font-size:18px;" solved the issue.
Post a Comment for "Itextshart Font Size Too Small: 0 Error"