Display XPS document with WCF service

Jun 25, 2013 at 2:07 PM
Edited Jun 25, 2013 at 3:41 PM
Hello All,

I am working on application which have so-many documents.
So I can't add each and every document in silverlight application.

So what I need, I can read bytes or lines through WCF and send data to silverlight application, now I tried below code, but I am unable to display document in XPS viewer.

/ ------ Service Call ------ /
Service1Client srvc = new Service1Client();
srvc.GetFileContentCompleted += new EventHandler<GetFileContentCompletedEventArgs>srvc_GetFileContentCompleted);

/ ------ Service Call Completed Event ------ /
void srvc_GetFileContentCompleted(object sender, GetFileContentCompletedEventArgs e)
        Stream sr = new MemoryStream();
        sr.Read(e.Result.GetFileContentResult, 0, e.Result.GetFileContentResult.Length);
        DataSource.PackageReader = new DefaultPackageReader(sr);

/ ------ WCF service method which read content and return stream ------ /
public Stream GetFileContent()
        string path = @"D:\BharatLeel\PracticeOrSampleApplication\4eDentalUniversitySolution\DentalChartSilverlightApp\Documents\sample.xps";
        StreamReader sr = new StreamReader(path);
        return sr.BaseStream;

Please do need full help.

Thanks in Advance.
Jul 2, 2013 at 1:35 PM
You'll need to reset the stream position before creating the DefaultPackageReader. Just set Stream.Position to 0.
Jul 10, 2013 at 1:08 PM
Edited Jul 10, 2013 at 1:09 PM
Hello kozw,
      First of all sorry for late reply, and Thanks for your guidance now it's working :)