Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The code below is just Generating PDf but all the format of the page is disturbed...Generating its own Format...


Is there any other Way

What I have tried:

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=" + txtApplicantName.Text + "Registration.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
printDIV.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.LEGAL, 60f, 80f, 60f, 40f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
Posted
Updated 22-Jun-18 1:32am
v2
Comments
jaket-cp 22-Jun-18 8:11am    
what is pdfWriter?
Jochen Arndt 22-Jun-18 8:36am    
We don't know how your HTML page looks and it's dimensions.

Maybe the content is too wide to fit on the page; especially with the rather large horizontal margins of about 2 inches.

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