Click here to Skip to main content
15,072,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
using itextsharp i am converting aspx page to pdf document,but in pdf file only one page is creating every time but still data is there in aspx page which was not created in pdf file.I am working with using C#,kindly give the solution as early as possible

private void ConvertPDF()
string path = Server.MapPath("~/Img/Student Photos//PDFFiles//");
path = path + objbllpreadm.objELLPreAdmission.User_id + ".pdf";

if (File.Exists(path))

attchmt = objbllpreadm.objELLPreAdmission.User_id + ".pdf";
string filename1 = "";
filename1 = objbllpreadm.objELLPreAdmission.User_id + ".pdf";

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=" + filename1);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);

var output = new FileStream(path, FileMode.Create);

StringReader sr = new StringReader(sw.ToString());

iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A3, 0f, 10f, 10f, 0f);

HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc, output);


catch (Exception exp)
var ErrorMessage = new JavaScriptSerializer().Serialize(exp.Message.ToString());

the above method i am using for converting the aspx page to pdf document,the code completely running,no errors throwing,after running the code one pdf file will download which contains 2 pages and one more file will create in "~/Img/Student Photos//PDFFiles//" folder which contains single page...remaining data not coming
Updated 27-May-14 1:21am
Kornfeld Eliyahu Peter 27-May-14 3:18am
Have you done anything so far? Show some effort (code or search)! As is it ain't a question...
karthik Udhayakumar 27-May-14 3:24am
pls use improve question widget ..produce your code and explain where you are stuck up or any (error or issue) for better answers from the community.

1 solution

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