Displaying an XPS document in Document Viewer
Asked Answered
B

1

7

I'm having a go with document viewer and XPS atm as I haven't tried it before. So I have a simple piece of code loading an XPS document and displaying it in the document viewer, however the document doesn't appear. The document viewer loads and a quick step through in debug mode tells me the information is there,it just won't show.

        dvDoc = new DocumentViewer();

        string fileName = null;
        string appPath = System.IO.Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentWindow)).CodeBase);

        if (type == "About")
            fileName = appPath + @"\Documents\About.xps";

        fileName = fileName.Remove(0, 6);
        XpsDocument doc = new XpsDocument(fileName, FileAccess.Read);

        dvDoc.Document = doc.GetFixedDocumentSequence();

All literature I can find tells me to do it this way yet it doesn't seem to work for me. I'm aware that document viewer doesn't like URI's, hence the filename.remove line.

Any suggestions as to what I'm missing.

Cheers, SumGuy

Budgerigar answered 27/7, 2009 at 11:53 Comment(0)
I
10

You've probably already figured this out by now since it's been almost a month.

It doesn't look like your document viewer is part of your xaml file. It looks like you are creating a new DocumentViewer object, but never adding it to the xaml file.

Instead of

dvDoc = new DocumentViewer();

Declare it in your xaml file:

<DocumentViewer Name="dvDoc" />
Inquest answered 21/8, 2009 at 16:33 Comment(1)
I hadn't actually been working on this particular project recently so no I hadn't noticed. But now that you mention it, it is pretty obvious. Cheers for answeringBudgerigar

© 2022 - 2024 — McMap. All rights reserved.