iTextSharp – Simplify Your HTML to PDF Creation

If you’ve ever had to generate PDFs on the fly then you may have run into iTextSharp, which is a port of iText for C#. It isn’t as straight forward as some people might like, but it is certainly a powerful tool once you figure it out.

Follow below article

http://somewebguy.wordpress.com/2009/05/08/itextsharp-simplify-your-html-to-pdf-creation/

must be placed inside a form tag with runat=server” error

Sometimes you can get “…must be placed inside a form tag with runat=server” error, when you deal with “asp:panel” or “asp:linkbutton” or whatever else scenarious when html form control needs to be rendered for the specified control at run time. The problem can be solved (thanks, Alex) ovverridingPage.VerifyRenderingInServerForm Method. Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.

So, the code would look like the following (rendering asp:panel containing controls itself):

private void Page_Load(object sender, EventArgs e)
{
    StringWriter stringWriter = new StringWriter();
    HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
    contentPanel.RenderControl(htmlWriter);
    string s = stringWriter.ToString();

    Response.Write(s);
    Response.End();
}

public override void VerifyRenderingInServerForm(Control control)
{
    return;
}

The report you requested requires further information

Solution:

ReportDocument docReport = new ReportDocument();
docReport.Load({report path});
string DBServer = {Database Server};
string DBName = {Database Name};
string DBUserName = {Database Server User};
string DBUserPass = {Database Server Password};
docReport.SetDatabaseLogon(DBUserName, DBUserPass, DBServer, DBName);
/* Use Datatable as Data Source, Don’t apply Data Set */
docReport.SetDataSource(Dt);
rptViewAdmissionSlip.ReportSource = docReport;
rptViewAdmissionSlip.DataBind();

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!