views:

211

answers:

1

Hi folks,

Basically I have embedded a xps file in a WPF application containing a XPSDocument Viewer as a resource.

On loading the application, I just want the document viewer to display that embedded resource.

public Page1()
{
  InitializeComponent();
  XpsDocument doc = new XpsDocument(SmartsysBrowser.Properties.Resources.test1, FileAccess.Read);
  docViewer.Document = doc.GetFixedDocumentSequence();
  docViewer.Focus();
}

however this command does not pass muster

  XpsDocument doc = new XpsDocument(SmartsysBrowser.Properties.Resources.test1, FileAccess.Read);

I do know that I need to type the filepath of the XPS document but since it is embedded as a resource, how to?

Thanks very much all.

Background: I am supposed to make a application that will display a confidential document and since it is also important to restrict copies of it being made/printed/circulated, I have decided a ClickOnce WPF XBAP application is the way to go. My reasoning, all copies of a ClickOnce application can be rendered useless once I remove the application from the webserver. Furthermore, it seems to be the cheapest and most viable way to protect a confidential document. Please do feel free to suggest alternatives. I am always keen to learn from you all.

A: 

As you're using embedded resources (i.e. non-WPF resource), you could use Assembly.GetManifestResourceStream to get a Stream from your resource name, then use the static Package.Open to get a Package instance, then you can use the other XpsDocument constructor that accepts a Package as parameter.

Timores