Click here to Skip to main content
Rate this: bad
good
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
Kurac1745
Comments
Prasad Khandekar at 22-Apr-13 16:26pm
   
Instead of .Body try Body & instead of font-size use size.
Kurac1 at 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 at 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
0 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 319
2 CPallini 275
3 DamithSL 214
4 Maciej Los 185
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 22 Apr 2013
Copyright © CodeProject, 1999-2014
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