The XPS is a Microsoft document standard, like Adobe's PDF, which now has a lot of PDF document online readers, and XPS document readers are few and far between. Today, I made this XPS document reader to share with you, and also hope that a master can solve some problems and common progress. The XPS reader can achieve the following effects: You can restore the original document, add page navigation (similar to Word title navigation, if it is a link to the external URL will open a new page), add a page animation effect (provides properties to customize the page animation).
With the release of SILVERLIGHT4, the Silverlight version of the XPS reader is also becoming viable. In fact, the foreign cattle early in the SILVERLIGHT3 issued XPS reader, but it is charged. The main reason is that all previous versions of SILVERLIGHT4 do not support setting the Fontsource property for glyphs. This leads to the purchase of a third party's class library unless you write another set of class libraries to simulate glyphs. But now Silverlight supports bit glyphs setting fontsource properties, so now we can design a Silverlight version of the XPS reader. The only regret is that you cannot read the XPS document that was printed directly from office, only to read XPS documents that were converted by Microsoft, and the problem was that when the XPS document was printed by the document, it was impossible to get the relevant resources (expect a master to solve them). The following figure is the class file for this project:
Almost all of the class files here are based on the XPS document structure. We can simply take out an XPS document converted by office, then change the file's suffix name to zip format, and then unzip the file to see the entire document's structure. The most important class in all classes has three: XpsDocument This class is the hosting document (that is, stream stream), Xpstosilverlightxaml This class is specifically responsible for converting XML into XAML (refer to a foreign blog, the name is forgotten), FixedPage This class is designed to host pages (for displaying pages), and other classes are designed to assist and work with the document structure.
In order to distinguish between office conversions, a Xpsdocumenttype enumeration is specifically used to represent the document type.
The other is not much to say, all in the source code inside. What do not understand can leave a message to me.
Then the following is the use of the XPS control:
1. First add the control's reference to the page xmlns:xps= "clr-namespace:mycontrol.xpsdocument;" Assembly=mycontrol "