How to create an XPS document in a WCF service to store and return?

亡梦爱人 提交于 2019-12-12 04:26:14

问题


I've got a WCF service as middle tier, and on some occasions I need to create a printable document, store it for future reference in the database, and return it to the client.

My first choice as file format was XPS, so I'd like to create an XPS document in a WCF service, store it, and return it.

Is there an easy way to achieve this, or some other obvious way to solve my problem (storing and returning a printable document in WCF) I've missed?


回答1:


Easy? Nothing's easy about XPS.

I'm currently serializing the XPS to a byte array using the XpsSerializerFactory

   using (MemoryStream ms = new MemoryStream())
    {
        var writer = new XpsSerializerFactory().CreateSerializerWriter(ms);
        writer.Write(fds);
        return ms.ToArray();
    }

I've toyed around with just sending the memory stream that backs the document's package across along with the URI of the document, but I've never tested that.



来源:https://stackoverflow.com/questions/321168/how-to-create-an-xps-document-in-a-wcf-service-to-store-and-return

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!