Read xps file from Webservice

Feb 11, 2011 at 9:22 AM
Edited Feb 11, 2011 at 11:05 AM

Hi there,

I'm currently evaluating the document tookit with a view to purchasing. My requirement is to stream xps documents from a webservice to be displayed in Silverlight.

So far I have successfully been able to display xps documents in your viewer Document Viewer when the xps file is included in the project as a resource file


DataSource.PackageReader  = new SharpZipPackageReader(new uri("some uri", UriKind.Relative))

However whenever I try to pass a stream from the webservice to the packageReader I get an error. Example Code:


Dim s as Stream = new MemoryStream

s.Write(e.Result, 0, e.Result.Length) // Stream returned from webservice

Datasource.PackageReader = new SharpZipPackageReader(s)


The error details are as follows

'Could not read the xps package. Either the package is not valid or the used package reader does not support the ZIP format of the package....."

The xps document I am streaming from the webservice is the same document that I had previously tested as a resource. Would appreciate any help you can offer as your product looks to be a good solution for us however we would have to be able to load documents from a stream.




Feb 11, 2011 at 11:13 AM

Have resolved the issue, was a few silly mistakes in my webservice. Documents now displaying as with the method above

Feb 11, 2011 at 2:24 PM

Good to hear you figured it out. FYI: the Loading Strategies sample also contains code where an XPS document is loaded from a webservice response stream.

- Koen