Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to read file XPS in C# , please help me
Posted

1 solution

You can do it in a WPF application.

This code sample is just few lines of code. You can find it here, at the very end of the MSDN help page on the class System.Windows.Xps.Packaging.XpsDocument in the section "Community Content":
http://msdn.microsoft.com/en-us/library/system.windows.xps.packaging.xpsdocument.aspx[^].

Don't forget: you need to add the reference to the assembly "ReachFramework.DLL" which is bundled with .NET Framework v.3.5 and later, so add it from the ".NET" tab of the window "Add Reference".

The idea is:
C#
//assuming this is the file name of some XPS document:
string fileName; //assign appropriate path name to it, from file dialog, for example

System.Windows.Controls.DocumentViewer viewer; //should be initialized and inserted in UI

//...

System.Windows.Xps.Packaging.XpsDocument doc =
    new System.Windows.Xps.Packaging.XpsDocument(fileName, System.IO.FileAccess.Read);
viewer.Document = doc.GetFixedDocumentSequence(); //viewing it!

It works, tested.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900