Saving PDF to the server

Dec 15, 2009 at 10: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 document.save 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.

 

Tami

 

Coordinator
Jan 12, 2010 at 8:19 PM

I add two test project. You could download them here http://silverpdf.codeplex.com/SourceControl/list/changesets

Look at ServerUpload and ServerUpload.Web projects.

 

 

Aug 26, 2010 at 5:56 PM

Hi.

 

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 7:05 PM

Hi,

I solve this.

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

Thanks anyway.

Marnei

        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);
            }
        }