views:

36

answers:

2

I developed a C# web application that calls a web-service which returns a base64 encoded array (PDF file). I then convert that array into a UCOMIStream object (I know it is obsolete, but the DLL that I am using requires it as a parameter). I use the following code to do the conversion which works perfectly. I can pass this object to the DLL so that I can print the PDF.

This works great on the Webserver, but the requirement is to print it locally.

        Byte[] bBuffer = statementOut.statementcycle.statementdata.content;
        int size = bBuffer.Length;
        IntPtr mem = Marshal.AllocHGlobal(size);
        Marshal.Copy(bBuffer, 0, mem, size);
        // Create an OLE Stream object.
        System.Runtime.InteropServices.UCOMIStream str;   //obsolete but the createstreamonhglobal outputs it
        CreateStreamOnHGlobal(mem, true, out str);

The DLL resides on the client so I am able to use ActiveX to create the object using javascript and/or VBscript;however, I have not been able to figure out how to get the stream object to the client to pass to the DLL.

How can this be achieved?

+1  A: 

Couldn't you just generate the pdf on the server and have the client download it?

Cannot generate the pdf on the server. We are looking for other means for it is a webserver farm and they are unsue whether or not the servers will have access to a fileshare.
Mark D
+1  A: 

Have the client download that base64 encoded array and then translate the data into a UCOMIStream object and generate the PDF the client side.

Mike Webb
Agreed. That was my other option, but I was unable to figure out how to translate the data into a UCOMIStream object with script. Can you provide?
Mark D
What do you mean "with script." Is the client app a C# app or something else? I think you should be able to just return the byte stream/array and print it to a file with a .pdf extension. As long as all the data gets passed down intact then the file should work perfectly fine.
Mike Webb
It is a web application however in order to print locally, you must use script such as javascript in order to access the client, etc for the script runs on the client. I cannot figure out a way to pass the stream from the server to the client. That is my original question. Once I get the stream down then I can just simply instantiate the PDF dll that is on the client and pass the stream to it in which it will print to the local printer. How do I get the stream object from the webserver so that I can access it with javascript and/or vbscript?
Mark D
Oh. The explanation was a little unclear on this. Thought you had a C# app that was accessing the web service. I did some looking and this is all I found so far. See if it helps any and let me know. <http://it.toolbox.com/blogs/paytonbyrd/successfully-stream-a-pdf-through-https-1554>
Mike Webb
Mike, Yes,I already do that but that renders the PDF document to the browser which is fine and then one can just print or save from there;HOWEVER, that is not the requirement. They want to print silently and locally. Hence, my dilemma of how to get my UCOMIStream objec down from the webserver to the client such that when I instantiate the ActiveX dll that takes in a UCOMIStream object, it will print it locally.
Mark D