Saving PDF to the server

Dec 15, 2009 at 11:06 PM

I need to create a PDF document which has a streetmap, some basic graphics (rectangle neatline), text title, graphic scalebar, etc.   This isn't too tough to do, as I have the code to save a writeablebitmap of the screen image for the map, but I would like to save the whole PDF server-side so that I can open it in a new browser window as a print preview. 

Any methods for saving the PDF I create?  The doesn't seem to support saving to anything but a string path, it will not take a URI so I cannot get the file saved to my server rather than the users local machine.




Jan 12, 2010 at 9:19 PM

I add two test project. You could download them here

Look at ServerUpload and ServerUpload.Web projects.



Aug 26, 2010 at 6:56 PM



The project isn't work for me. I get an error on the line:

while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)
of method PushData. The input.CanRead, CanSeek, CanAnything is false.
the error message is: "Cannot access a closed Stream."
can u help me?
thanks a lot.
Aug 26, 2010 at 8:05 PM


I solve this.

I create a new memorystream and read it, that is a copy of the original stream.

Thanks anyway.


        private static void PushData(Stream input, Stream output)
            byte[] buffer = new byte[4096];
            int bytesRead;

            MemoryStream m = new MemoryStream((input as MemoryStream).ToArray());

            while ((bytesRead = m.Read(buffer, 0, buffer.Length)) != 0)
                output.Write(buffer, 0, bytesRead);