views:

327

answers:

1

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  A: 

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.

Will