Read from MemoryStream

Feb 1, 2011 at 3: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.

Feb 1, 2011 at 10:03 PM
Edited Feb 1, 2011 at 10: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

Hope this helps,