Click here to Skip to main content
11,417,390 members (53,304 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hi,

Im trying to create pdf file using itextsharp so that im using the below code.
im getting the >>>>Error: The document has no pages.<<<<

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=UserDetails.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.A2, 7f, 7f, 7f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();

Thanku.
Posted 11-Oct-12 0:01am
Edited 11-Oct-12 0:21am
_Amy52.4K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

hi

check out the following link[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

why don't you use. PdfSharp ? it is an open source, easy to use and very wide library. using this u can generate almost any kind of pdf in your own format. give it a try you will get lots of examples also to start in minutes.
follow this link: http://www.pdfsharp.com/[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sascha Lefévre 340
1 Abhinav S 303
2 OriginalGriff 235
3 Sergey Alexandrovich Kryukov 215
4 Richard Deeming 125
0 Sergey Alexandrovich Kryukov 9,345
1 OriginalGriff 7,712
2 Maciej Los 3,758
3 Abhinav S 3,601
4 Sascha Lefévre 3,198


Advertise | Privacy | Mobile
Web03 | 2.8.150427.4 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2015
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