Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - How to use document viewer?

 
 
Old 03-10-2006   #1 (permalink)
John Lorenzen


 
 

How to use document viewer?

Does anyone know how to load a document in the document viewer?



My System SpecsSystem Spec
Old 03-10-2006   #2 (permalink)
Derek Mehlhorn - MSFT


 
 

RE: How to use document viewer?

First you have to have the correct kind of document, if you are trying to
load an XPS document, you can use the Packaging apis to load the file, get
access to the FixedDocumentSequence, and set it on the DocumentViewer:

DocumentViewer viewer = new DocumentViewer();
XpsDocument doc = new XpsDocument(filename, FileAccess.Read);
viewer.Document = doc.GetFixedDocumentSequence();

If you are trying to directly load a FixedDocument or FixedDocumentSequence
that is outside your assembly (e.g. not compiled into your app) you can use:

IDocumentPaginatorSource doc = (IDocumentPaginatorSource)
XamlReader.Load(Stream);

This will parse the stream and create the corresponding WPF object which you
can set on the viewer. Note: this approach can be a bit trickier because the
relative paths in the document definition might be off depending on the
document's location relative to the executable.

Finally if you are trying to load a FixedDocument or FixedDocumentSequence
directly AND it has been compiled into your app, you can use:

IDocumentPaginatorSource doc = (IDocumentPaginatorSource)
XamlReader.Load(Application.GetResourceStream(fileUri).Stream);

Hope this helps.
-Derek
http://blogs.msdn.com/mehlhorn/default.aspx
My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Windows Photo Viewer zoom vs. Picture/Fax Viewer Vista music pictures video
Replace Picture & Fax Viewer with a new, lightweight image viewer Vista print fax & scan
document viewer .NET General
View and copy document content without opening the document Vista performance & maintenance
Re: XPS Viewer and Printing to MS XPS Document Writer Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46