如何在WCF服务中创建XPS文档以存储和返回? [英] How to create an XPS document in a WCF service to store and return?

查看:97
本文介绍了如何在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.

我首先选择的文件格式是XPS,所以我想在WCF服务中创建XPS文档,将其存储并返回.

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.

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

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?

推荐答案

容易吗? XPS绝非易事.

Easy? Nothing's easy about XPS.

我目前正在使用XpsSerializerFactory将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();
    }

我只是在发送仅支持文档包的内存流以及文档的URI,但我从来没有对此进行过测试.

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.

这篇关于如何在WCF服务中创建XPS文档以存储和返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆