Tutorials index / Example 18: Realtime
PDF export from a web application
This example illustrates
how to create PDF file with a nice chart on
the fly a web browser. No temporary files are involved.
Hint: this is a great
and easy way to print your charts !!
Steps:
1. Create a new ASP.NET
application project (C#)
2. Add a reference to
Super 2d/3d Graph Library and to
System.Windows.Forms (this one is necessary
for the library to operate on web
environments)
3. Insert the
following code in the Page_Load event.
4. Run!
Form Code
Insert this code in the Page_Load event:
Super2d3dGraphLibrary.Super2d3dGraph
oGraph =
new
Super2d3dGraphLibrary.Super2d3dGraph();
oGraph.LicenseeIdentifier =
"PROF";
// Create a quick and random sample chart
oGraph.SampleChart();
// Increase resolution of chart (great for
printing!)
oGraph.Resolution = 150;
// Paint the chart
oGraph.RefreshChart();
// Output the chart to the browser
Response.Clear();
Response.ContentType =
"Application/pdf";
byte[]
pdf = oGraph.CreatePDF(Super2d3dGraphLibrary.STYLE_ORIENTATION.ORIENTATION_LANDSCAPE,
75,
true);
Response.OutputStream.Write(pdf, 0, pdf.Length);
Result:
(This is not an image -
it's your PDF Reader showing a sample chart
in PDF format)
|