I am trying to convert webpage into pdf using itextsharp,
Following is the c# code I am using
Java
protected void btnExport_Click(object sender, EventArgs e)
{
try
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 5f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
StyleSheet ST = new StyleSheet();
FontFactory.Register("c:\\windows\\fonts\\Times.ttf");
ST.LoadTagStyle("body", "face", "Times New Roman");
ST.LoadTagStyle("body", "size", "15px");
htmlparser.SetStyleSheet(ST);
//XMLWorkerHelper worker = XMLWorkerHelper.GetInstance();
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
catch (Exception EX)
{ }
}below is a source code:
1. Personal Details
Maiden name (If any)* :
Father's/Spouse Name* :
Mother name* :
Date of birth* :
Gender* :
Marital status* :
Citizenship* :
Residential status* :
Occupation Type* :
Adhar Card* :
2. Residence for tax purposes in jurisdiction(s) outside India
3. Address
4. Contact Details
5. Applicant Decalartion
Annexture- 3
TRADING AND DEMAT ACCOUNT RELATED DETAILS
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
1 short reply
Arul Rethinam49 pointsPosted Nov 2, 2017, 5:03 AM EDT