I new in using ITextSharp and want create a simple pdf file. And I trying in localhost, it work fine but put in server it fail to create and show the error message " The document has no pages.". I got try find the solution in web but still the same. How to solve this kind of problem?
Below is my coding.
var html = GenerateHTML(lst, getuser);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Commision_" + name + "_" + DateTime.Now.ToString("yyyyMM") + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
//Render PlaceHolder to temporary stream
StringReader reader = new StringReader(html);
//Create PDF document
Document doc = new Document(PageSize.A4);
HTMLWorker parser = new HTMLWorker(doc);
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
try
{
doc.NewPage();
parser.Parse(reader);
}
catch (Exception )
{
}
finally
{
doc.Close();
}
catch
clause. You may be hiding an error. – David Crowell