Wednesday, October 06, 2004

Active Reports - Exporting in PDF for the Web

I've been playing with Active Reports for a little while now and I like it. It wasn't entirely clear how to export as pdf, which is something I really needed to do. If you're wondering, here's how it is done.

//This would be the actual report file in your application.
//The class name = the name of the report
ReportFile rpt = new ReportFile();
rpt.Run();

Document doc = rpt.Document;

MemoryStream stream = new MemoryStream();

PdfExport exp = new PdfExport();
exp.Export(doc, stream);

Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.BinaryWrite(stream.ToArray());
Response.End();
stream.Close();

Make sense? Hope so.

0 Comments:

Post a Comment

<< Home