如何在WCF服务中创建XPS文档来存储和返回?

发布于 2024-07-10 02:52:38 字数 197 浏览 5 评论 0原文

我有一个 WCF 服务作为中间层,在某些情况下,我需要创建一个可打印文档,将其存储在数据库中以供将来参考,然后将其返回给客户端。

我的首选文件格式是 XPS,因此我想在 WCF 服务中创建 XPS 文档、存储它并返回它。

有没有一种简单的方法可以实现此目的,或者有其他一些明显的方法来解决我错过的问题(在 WCF 中存储和返回可打印文档)?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最后的乘客 2024-07-17 02:52:38

简单的? XPS 绝非易事。

我目前正在使用 XpsSerializerFactory 将 XPS 序列化为字节数组,

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

我曾尝试过仅发送支持文档包的内存流以及文档的 URI,但我从未对此进行过测试。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文