Click here to Skip to main content
12,068,520 members (71,387 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: itextsharp
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
var parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(mainContents), styles);

but dont really now how to write that
Posted 22-Apr-13 10:56am
Kurac1866
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160208.1 | Last Updated 22 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100