![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | How to use document viewer? Does anyone know how to load a document in the document viewer? |
My System Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| 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 | |||