Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 02, 2012 06:11 AM by anup ganatra
Feb 29, 2012 09:52 AM|LINK
I am generating pdf reports from the following code.But when I open the pdf files it gives me error.Tell me where I am going wrong.PDF files is generated successfully.Also If I generate reports in excel form it runs fine.
public override void VerifyRenderingInServerForm(Control control)
/* Confirms that an HtmlForm control is rendered for the specified ASP.NET
server control at run time. */
protected void btnPrint_Click(object sender, EventArgs e)
Response.Charset = "";
// If you want the option to open the Excel file without saving then
// comment out the line below
Response.ContentType = "application/vnd.pdf";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Feb 29, 2012 12:48 PM|LINK
What error it gives you (error message). Do you use itextsharp to print pdf? Maybe you forgot close filestream after writing pdf file?
Here you can read about printing gridview to pdf http://www.aspsnippets.com/Articles/Export-GridView-To-Word-Excel-PDF-CSV-Formats-in-ASP.Net.aspx.
Mar 02, 2012 06:11 AM|LINK
But I have colourful gridview so when I export gridview with word,excel or pdf it comes with colours.So I want exported gridview in simple form.And also My gridview is having page numbers so they are also displayed in exported gridview.Also when if I am
using GridView1.DataBind(); inside the click event of print button then output comes like
So when I have deleted GridView1.DataBind(); then output came normally.