Visual Mining contact us | site map | search

Products Solutions Resource Library Services Customers Partners Developers Company
Developers

NetCharts® Server: ASP.NET Toolkit retrievePDF Example using C#

This example shows how to utilize the NetCharts Server ASP.NET Toolkit to retrieve a a generated report as PDF from NetCharts Server using C#.

Source Code

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace cstoolkitexample
{
/// <summary>
/// Summary description for retrievePDF.
/// </summary>
public class retrievePDF : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
string serverName = System.Configuration.ConfigurationSettings.AppSettings["serverName"];
short serverPort = Convert.ToInt16(System.Configuration.ConfigurationSettings.AppSettings["serverPort"]);
NetChartsServer.NSToolKit toolKit = new NetChartsServer.NSToolKit("Examples/Finance", serverName, serverPort);
Hashtable ht = new Hashtable();
ht.Add("type", "PDF");

// Set the appropriate content type.
Response.ContentType = "Application/pdf";
// Set the header to instruct the browser as to the file name.
Response.AddHeader("Content-Disposition", "inline; filename=report.pdf");
// Write the file directly to the HTTP output stream.
Response.BinaryWrite(toolKit.getPDFReport("Costs.pgl", ht));
Response.End();
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}


© 2008 Visual Mining, Inc. All rights reserved.
1-800-308-0731 | info@visualmining.com | privacy statement | legal
15825 Shady Grove Rd., Suite 20, Rockville, MD 20850 USA
Quote: US Geological Survey