I have a byte array of xps file content stored in a sql server, I'm trying to retrieve it back and display it into a DocumentViewer
control.
cmd.CommandText = "select text from [table] where docName = '" + selectedText + "'";
using (SqlDataReader read = cmd.ExecuteReader())
{
while (read.Read())
{
byte[] retrieve = ((byte[])read["text"]); //text is column name for the byte array
var package = System.IO.Packaging.Package.Open(new MemoryStream(retrieve));
var xpsDocument = new XpsDocument(package, System.IO.Packaging.CompressionOption.Maximum);
pptViewer.Visibility = System.Windows.Visibility.Visible;
pptViewer.Document = xpsDocument.GetFixedDocumentSequence();
}
}
The issue is this line new XpsDocument(package, System.IO.Packaging.CompressionOption.Maximum)
requires an extra parameter - the Uri of the file. I don't have it as it isn't stored locally - I convert it to a byte array and then store it, so the original xps file is gone.
Is possible to convert the byte array into an xps document without any uri? If not, how else can I display the document inside my wpf app (from a byte array, of coruse)?