Download presentation
Presentation is loading. Please wait.
Published byShannon French Modified over 8 years ago
1
1 Unleashing The Power Of XPS-Based File Formats For Your Application Jesse McGatha DAT304 Program Manager Microsoft Corporation
2
2 Session Outline Packages File Format Definitions Developer Scenarios Package Overview (Demo) Package Services Core Properties Digital Signatures (Demo) Rights Management Custom File Formats Solution Development XPS Extensibility
3
3 Session Goals Understand the basic package architecture Basic package format Package services Explore different formats built on packages XPS Documents Office “12” files (.docx,.pptx,.xlsx) Custom formats Understand the benefits of the architecture TransparencyFlexibilityRobustness Reduced sustained engineering cost Many developer opportunities
4
4 File Format Definitions XPS: The XML Paper Specification Packages: The foundation of many file formats ZIP Parts and Relationships Abstraction Custom Formats Office “12” Open XML Formats Package Services Open Packaging Conventions Specification XPS Document Format XML Paper Specification
5
5 Package And XPS Technologies Open Packaging Conventions and XML Paper Specification (XPS) for use by devices and any application on any platform. Open Specifications A WPF utility that allow users to view, protect and print XPS Documents. Hosted in IE. XPS Viewer A print-to-file converter for creating XPS Documents from any Microsoft Windows-based application. Print Driver to “Save As” XPS Document Application programming interfaces (APIs) to manage package and content. WinFX APIs Print pipeline with integrated spool format and printer-page description language to speed and improve print jobs fidelity. New driver model. XPS Print Path
6
6 Developer Scenarios Build custom file formats Access XPS Document and Office “12” content directly Provide document solutions for XPS Document, Office “12” or custom files WinFXAPIs WinFX XPS Document API XPS Document Format WinFX Package API Applications Custom Format Custom APIs Office “12” Open XML Formats
7
7 Packaging Model Provides foundation of a file format Described in the Open Packaging Conventions Specification v0.75 Usable by any application Multiple implementations underway XPS Document and Office “12” Open XML formats Built on concepts of parts and relationships Parts are streams of data (XML or binary) Relationships describe how parts are related Stored in a ZIP archive
8
8 Inspecting A Package Using ZIP Utilities
9
9 Packaging APIs Classes WinFX provides an API to make package manipulation easy API is in System.IO.Packaging namespace Classes of interest PackagePackagePartPackagePartCollectionPackageRelationshipPackageRelationshipCollectionPackUriHelperPackWebRequestPackWebResponse
10
10 Packaging APIs API Functionality Open and close packages Create and delete parts and relationships Get the name, content-type, and stream for parts Read and write part streams Get the ID, type, and target URI for relationships
11
11 Packaging APIs Sample code – read data from package // Open existing package Package package = Package.Open(“C:\Temp\PDCfile.docx”, FileMode.Open); // Find parts based on relationship type string relType = “http://schemas.microsoft.com/office/2006/relationships/officeDocument”; PackageRelationshipCollection packRels = package.GetRelationshipsByType(relType); // Assuming there is only one relationship of this type IEnumerator relsEnumerator = packRels.GetEnumerator(); relsEnumerator.MoveNext(); PackageRelationship rel = relsEnumerator.Current; // For this sample, fetch only the first part in this collection PackagePart part = package.GetPart( PackUriHelper.ResolvePartUri( new Uri(“/”, UriKind.Relative), rel.TargetURI)); // Get the stream for this part Stream partStream = part.GetStream();
12
12 Package Services
13
13 Common Package Services WinFX provides APIs for common package services Core Properties Digital Signatures Rights Management
14
14 Core Properties Package may include a set of metadata in a single XML part: The core properties part Discovered by a root relationship with a specific relationship type Uses a specific content type XPS Document and Office “12” files both support core properties Category Content Status ContentType Creator DateCreated DateModified Description Identifier Keywords Language LastModifiedBy LastPrinted Revision Subject Title Version Core Properties XPS Package Relationships Common Package Parts Core Properties
15
15 Digital Signatures Allow you to validate that the signed content has not been tampered with Available for all package-based file formats Follow well-known standards: Compatible with the XML Digital Signature standard Certificates follow X509 standard Parts signed are determined by the signing policy Example: XPS Document policy is to sign all defined parts and relationships Can be extended by the particular format
16
16 Digital Signatures Model Signature Origin part is the root of all signatures in the package Each signature located in its own part XPS Package Relationships Common Package Parts Core Properties Signature Origin X509 Cert Signature X509 Cert Signed part Signature Resources Signed Parts RecommendedParts Relationship URI Reference
17
17 Digital Signatures APIs Classes of interest PackageDigitalSignatureManager: Get, add, or remove a signature to/from the package PackageDigitalSignature Get the list of parts signed by the signature Get the list of references to signed relationships Get the list of signed and unsigned objects in the signature Verify the signature Verify the signature certificate PackageDigitalSignaturePackageDigitalSignatureManager
18
18 Digital Signatures
19
19 OLE Property Storage Core Properties RM “envelope” RM Licenses XPS Package Relationships Common Package Parts Core Properties Signature Origin Signature X509 Cert Signature X509 Cert Signed part Rights Management May use any RM solution RM is external to the XPS Specification Windows RMS solution provided with WinFX Allows easy participation in RMS document workflows API wraps the unmanaged RMS API In the System.Security.RightsManagement namespace
20
20 Custom File Formats
21
21 Custom File Formats Creating your own Microsoft encourages applications to adopt the packaging model for file management WinFX APIs make this easy Makes building solutions around your application easier Factor your data Decide how to split your application’s data between parts Use XML parts to store data that can be represented textually Use binary parts to store other data For XML parts, define your own namespace
22
22 Custom File Formats More on creating your own Make use of relationships Define your own relationship types Prefer relationships over inline URI references They are a great way to attach a metadata part to other parts (particularly binary parts) Take advantage of common package services E.g. core properties, digital signatures
23
23 XPS Document Implementation
24
24 XPS Document Parts and relationships Key XPS Document parts FixedDocumentSequence – Root of the document FixedDocument – Document XML markup FixedPage – Page XML markup Font – Embedded font Image – Embedded image Thumbnail – Page thumbnail images PrintTicket – Printer settings for page/document DocumentStructure– Semantic structure of document StoryFragments– Semantic structure of page Key XPS Document relationships StartPart– Points to the FixedDocumentSeq. RequiredResource– Image/font needed to render page PrintTicket– Printer settings
25
25 XPS Document Format XPS Package Relationships Common Package Parts Core Properties Thumbnail Signature Origin Signature X509 Cert Fixed Payload Parts FixedDocumentSequence FixedDocument FixedPage DocumentStructure Font Fonts & Images Thumbnail All parts signed Resources OptionalParts Required or RecommendedParts Relationship URI Reference
26
26 XPS Documents Solution development APIs Supersede package APIs for XPS Document solutions Create, consume, and service XPS Documents Tailored to the specific needs of XPS Documents API is in System.Windows.Xps.Packaging namespace Classes of interest XpsDocumentIDocumentSequenceReaderIDocumentSequenceWriterIFixedDocumentReaderIFixedDocumentWriterIFixedPageReaderIFixedPageWriter
27
27 XPS Documents API functionality Document manipulation Add/remove documents to document sequence and pages to documents Retrieve or set core properties Retrieve or set thumbnails Add page content E.g. colors, fonts, images, resource dictionaries Retrieve/Set PrintTickets (print job control XML) Digital Signatures Automatically sign according to XPS Document signing policy Specify co-signature requirements
28
28 XPS Document Extensibility XPS Documents may be extended through the use of markup compatibility Identical to Windows Presentation Foundation (XAML) markup compatibility Designed to support backward and forward compatibility The only proper way to add new features intermixed with XPS Document markup XPS Viewer will reject files with unknown markup
29
29 XPS Document Markup compatibility XML parts are processed for compatibility during loading Process unknown XML namespaces, elements, and attributes By default, unknown elements/attributes trigger errors Ignorable suppresses errors triggered by elements/attributes in unknown namespaces ProcessContent determines if markup nested within an ignored element should be processed AlternateContent selects a Choice based on Required namespaces MustUnderstand triggers an immediate error when an unknown namespace is specified
30
30 XPS Document Markup compatibility sample <FixedPage Height="1056" Width="816" xml:lang="en-US" xmlns="http://schemas.microsoft.com/xps/2005/06" xmlns="http://schemas.microsoft.com/xps/2005/06" xmlns:mc="http://schemas.microsoft.com/winfx/markup- compatibility/2005" xmlns:mc="http://schemas.microsoft.com/winfx/markup- compatibility/2005" xmlns:mcext="http://schemas.example.com/PDC/example/extension1" xmlns:mcext="http://schemas.example.com/PDC/example/extension1" mc:Ignorable="mcext" > mc:Ignorable="mcext" > <Path Stroke="#000000" <Path Stroke="#000000" Data="M 20,70 A 50,50 0 1 1 120,70 A 50,50 0 1 1 20,70 Z" /> Data="M 20,70 A 50,50 0 1 1 120,70 A 50,50 0 1 1 20,70 Z" /> <Path <Path mcext:Finish="GoldVarnish" mcext:Finish="GoldVarnish" Data="M 20,70 A 50,50 0 1 1 120,70 A 50,50 0 1 1 20,70 Z" /> Data="M 20,70 A 50,50 0 1 1 120,70 A 50,50 0 1 1 20,70 Z" /> <Path <Path Fill="#C8C800" Fill="#C8C800" Opacity="0.2" Opacity="0.2" Data="M 20,70 A 50,50 0 1 1 120,70 A 50,50 0 1 1 20,70 Z" /> Data="M 20,70 A 50,50 0 1 1 120,70 A 50,50 0 1 1 20,70 Z" /> </FixedPage>
31
31 Conclusion
32
32 Benefits Transparency Really see what is in your files Great for archiving – you don’t need particular applications Flexibility Formats are extensible with custom data Formats can easily be integrated into solutions and workflows Robustness ZIP is recoverable Compression benefits file size Reduced sustained engineering costs Use the WinFX API for managing files rather than a custom API Lots of developer opportunities Open formats do not require integration of the original application to build a solution Packages and XPS Documents a broader part of a full suite of technologies
33
33 Community Resources At PDC For more information, go see PRS333 – Advances in Document Workflow, Securing, Viewing, and Printing Your Content OFF304 – Developing for the 'Office12' User Experience OFF415 – Developing Custom Workflows in ‘Office 12’ Presentation Track Lounge Hands on Labs PRSHOL27 Extend the XPS Document Viewing Experience PRSHOL12 WinFX Printing and Archiving PRSHOL11 Programming XPS Documents Package and XPS related information: Specifications: http://www.microsoft.com/whdc/xps Email: prninfo@microsoft.com XPS conformance test suite planned for Windows Vista WDK Beta 2 Office Open XML formats Office Preview Site: http://www.microsoft.com/office/preview/ Brian Jones’s Blog: http://blogs.msdn.com/Brian_Jones/ Office 2003 Reference Schema Information: http://www.microsoft.com/office/xml/
34
34 © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
35
35 Appendix: Digital Signatures Sample code // Assume package contains the Package to sign PackageDigitalSignatureManager dsm = new PackageDigitalSignatureManager(package); // Get all Parts and add them to the List of Parts to be signed. // Cannot pass GetParts() enumeration directly as it is // invalidated during Sign process. List toSign = new List (); foreach (PackagePart packagePart in package.GetParts()) { toSign.Add(packagePart.Uri); toSign.Add(packagePart.Uri);} // Normally, you wrap this in a try/catch to detect // when no certificates are available... dsm.Sign(toSign); // Prompt user to select a Cert to sign with
36
36 Appendix: Core Properties Markup sample Jesse McGatha Jesse McGatha PDC Presentation PDC Presentation XML File Formats XML File Formats Presentation Presentation XML;XPS;Office;Format XML;XPS;Office;Format PDC presentation on XML file formats. PDC presentation on XML file formats. Presentation Presentation Final Final 1.0 1.0 231 231 07/21/2005 10:00:00 07/21/2005 10:00:00 07/22/2005 12:00:00 07/22/2005 12:00:00 Jesse McGatha Jesse McGatha 07/22/2005 12:00:00 07/22/2005 12:00:00 EN-US EN-US DAT011 DAT011 </CoreProperties>
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.