Monday, March 12, 2012

Programmatically Saving As PDF?

Ok. So I have this ASP.NET page and I've programmatically taken a report from the report server and rendered it in PDF. Now I would like to take this a step further and save the report as a pdf document on the local machine.

So at this point I have a byte array representing the document, now how would I save this as a pdf on the local machine? I'm unaware of an ASP Response method to allow this and I'm unaware of a SSRS ReportingService method, but as I said I'm unaware...

Any ideas, thoughts, resources are all welcome.

Well, the answer was actually quite easy to implement as the code below shows...

using (FileStream stream = File.OpenWrite(resultByte))

{

stream.Write(resultByte, 0, resultByte.length);

}

For those that may be interested in the full implementation then check out this article at http://www.codeproject.com/sqlrs/PDFUsingSQLRepServices.asp?df=100.

No comments:

Post a Comment