Read from MemoryStream

Feb 1, 2011 at 2:17 PM

Hello All,

 

Here is what I want to do -  create an XPS document using the Siberix Report Writer and store it in a MemoryStream.  Having done so load from the memorystream the document for display in Silverlight using DocumentToolkit. It is not clear to me if/how I can get DocumentToolkit to read the contents of the XPS in the memory stream.  I imagine there is a way.  Any help would be much appreciated.

Coordinator
Feb 1, 2011 at 9:03 PM
Edited Feb 1, 2011 at 9:03 PM

Hi KwikSilver,

Something like this should work;

 

var stream = new MemoryStream(..); // stream containing XPS document
var reader = new DefaultPackageReader(stream);

this.DataSource.PackageReader = reader;

Where DataSource is referencing an instance of a DocumentDataSource.

It's highly recommended to use a 3rd party package reader instead of using the DefaultPackageReader. See also http://documenttoolkit.codeplex.com/wikipage?title=How%20To%20Use%20A%20Custom%20Package%20Reader

Hope this helps,

Koen