Hi,
Due to security patch update dated 13 dec 2022 on machine, XPS document is unable display on DocumentViewer UI control.Although microsoft provided an workaround regarding this. But can any one please help me out is there any other control availabe in WPF that can dispaly the XPS document.
Please let me know
Thanks
Marvin ReidPosted Jul 19, 2023, 3:26 PM
You can load that XPS file using the WPF DocumentViewer provided through the LEADTOOLS SDK. Here is some sample code that highlights the tutorial:
https://www.leadtools.com/help/sdk/tutorials/dotnet-wpf-display-files-in-the-document-viewer.html
Praveen MishraPosted Jul 13, 2023, 8:57 AM
Hi David ,
Add a reference to the
WindowsBaseandPresentationCoreassemblies in your project. These assemblies are required to work with XPS documents.In your XAML file, add the
DocumentViewercontrol to your UI layout.In your C# code, you need to load and display the XPS document using the
DocumentViewerIn the
LoadXpsDocument()method, you create an instance of theXpsDocumentclass by providing the path to your XPS document file. Then, you set theDocumentproperty of theDocumentViewercontrol to theFixedDocumentSequenceobtained from theXpsDocument.Make sure to replace
"path_to_your_xps_file.xps"with the actual path to your XPS document.That's it! When you run your application, it should load and display the XPS document in the
DocumentViewercontrol.David BrownPosted Jul 11, 2023, 2:20 PM
Consider using a FixedDocument control: Create a FixedDocument object and add the XPS document to it, then set it as content into a DocumentPanel control or other container.
Naimish MakwanaPosted Feb 2, 2023, 6:33 AM
Hello Saumya,
You can use the "FlowDocumentReader" control to display an XPS document in WPF.
You can get more details here: https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.flowdocumentreader?view=windowsdesktop-7.0
Thanks
Naimish