I am generating PDF using iTextSharp.dll, but the problem is that I am not able to apply that CSS. I have one div:
<div id="personal" class="headerdiv">
Personal Data
</div>
now my .aspx.cs code is like this:
iTextSharp.text.html.simpleparser.StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
styles.LoadTagStyle("#headerdiv", "height", "30px");
styles.LoadTagStyle("#headerdiv", "font-weight", "bold");
styles.LoadTagStyle("#headerdiv", "font-family", "Cambria");
styles.LoadTagStyle("#headerdiv", "font-size", "20px");
styles.LoadTagStyle("#headerdiv", "background-color", "Blue");
styles.LoadTagStyle("#headerdiv", "color", "White");
styles.LoadTagStyle("#headerdiv", "padding-left", "5px");
HTMLWorker worker = new HTMLWorker(document);
worker.SetStyleSheet(styles);
// step 4: we open document and start the worker on the document
document.Open();
worker.StartDocument();
// step 5: parse the html into the document
worker.Parse(reader);
// step 6: close the document and the worker
worker.EndDocument();
worker.Close();
document.Close();
See Question&Answers more detail:os