Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
const string classValue = "Body";
hTextWriter.AddAttribute(HtmlTextWriterAttribute.Class, classValue);
hTextWriter.RenderBeginTag(HtmlTextWriterTag.Div);
LabelFirstName.RenderControl(hTextWriter);


styles.LoadTagStyle(".Body", "font-size", "60pt");
hTextWriter.RenderEndTag();


i think also that i should write this
C#
var parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(mainContents), styles);


but dont really now how to write that
Posted
Comments
Prasad Khandekar 22-Apr-13 16:26pm    
Instead of .Body try Body & instead of font-size use size.
Kurac1 22-Apr-13 16:36pm    
Here i my code

{
using (var db = new knowitCVdbEntities())
{
var theEmpl = (from p in db.EMPLOYEES
where p.username == strUserName
select p).FirstOrDefault();


if (theEmpl != null)
{


string sDirPath = Server.MapPath("~/PDF_WORD/Docs");



var ObjSearchDir = new DirectoryInfo(sDirPath);
if (!ObjSearchDir.Exists)
{
ObjSearchDir.Create();
}
string strFileName =
HttpContext.Current.Server.MapPath("~/PDF_WORD/Docs/Test." +
DropDownListDownloadCv0.SelectedValue.ToString() +
"");
var objfileinfo = new FileInfo(strFileName);
// step 1: creation of a document-object
var document = new Document(PageSize.A4);



if (objfileinfo.Exists)
{
File.Delete(strFileName);
PdfWriter.GetInstance(document, new FileStream(strFileName, FileMode.Create));
}
else
PdfWriter.GetInstance(document, new FileStream(strFileName, FileMode.Create));



var sb = new StringBuilder();
var sw = new StringWriter(sb);

document.Open();
var hTextWriter = new HtmlTextWriter(sw);
var styles = new iTextSharp.text.html.simpleparser.StyleSheet();

const string classValue = "Body";
hTextWriter.AddAttribute(HtmlTextWriterAttribute.Class, classValue);
hTextWriter.RenderBeginTag(HtmlTextWriterTag.Div);

styles.LoadTagStyle("Body", "size", "60pt");

LabelFirstName.RenderControl(hTextWriter);
hTextWriter.RenderEndTag();

String strHtml1 = sw.ToString();

var hw = new iTextSharp.text.html.simpleparser.HTMLWorker(document);
hw.SetStyleSheet(styles);

hw.Parse(new StringReader(strHtml1));

document.Close();


}
Kurac1 22-Apr-13 16:38pm    
i solved it but al text get big i only want that label?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900