Saving Object as System.IO.Stream

bbrian51
bbrian51 used Ask the Experts™
on
Hi,

I am having issues converting my PDF object into a Byte() to print. I have a object called myPDF that has the following method definition:

myPDF.SaveMergedPDFToStream(outPDFStream AS System.IO.Stream)

My print routine has the following definition:

myPrinter.SendBytesToPrinter(Bytes() AS Byte)


I can make it work saving the file to disk and then reading it back in...but that seems pointless.

Thanks,
Brian
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:
You can use Read method of stream to convert stream to byte array

http://msdn.microsoft.com/en-us/library/system.io.stream.read.aspx
Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015
Commented:
Why not use a MemoryStream? It inherits from the Stream class. You would need to ensure the Position property is set to zero, then simply call the ToArray method to get the bytes within the stream.

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial