1 / 36

Unleashing The Power Of XPS-Based File Formats For Your Application

Unleashing The Power Of XPS-Based File Formats For Your Application. Jesse McGatha DAT304 Program Manager Microsoft Corporation. Session Outline. Packages File Format Definitions Developer Scenarios Package Overview ( Demo ) Package Services Core Properties Digital Signatures ( Demo )

zarita
Download Presentation

Unleashing The Power Of XPS-Based File Formats For Your Application

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unleashing The Power Of XPS-Based File Formats For Your Application Jesse McGatha DAT304Program ManagerMicrosoft Corporation

  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. 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 • Transparency • Flexibility • Robustness • Reduced sustained engineering cost • Many developer opportunities

  4. Office “12” Open XML Formats File Format Definitions • XPS: The XML Paper Specification • Packages: The foundation of many file formats Custom Formats XPS Document Format XML Paper Specification Package Services Parts and Relationships Abstraction ZIP Open Packaging Conventions Specification

  5. Open Packaging Conventions and XML Paper Specification (XPS) for use by devices and any application on any platform. Open Specifications 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 A print-to-file converter for creating XPS Documents from any Microsoft Windows-based application. Print Driver to “Save As” XPS Document A WPF utility that allow users to view, protect and print XPS Documents. Hosted in IE. XPS Viewer Package And XPS Technologies

  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 WinFX APIs Applications Custom APIs WinFX XPS Document API WinFX Package API Custom Format XPS Document Format Office “12” Open XML Formats

  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. Inspecting A Package Using ZIP Utilities

  9. Packaging APIs Classes • WinFX provides an API to make package manipulation easy • API is in System.IO.Packaging namespace • Classes of interest Package PackagePart PackagePartCollection PackageRelationship PackageRelationshipCollection PackUriHelper PackWebRequest PackWebResponse

  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. 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. Package Services

  13. Common Package Services • WinFX provides APIs for commonpackage services • Core Properties • Digital Signatures • Rights Management

  14. CoreProperties • CategoryContent StatusContentTypeCreatorDateCreatedDateModifiedDescriptionIdentifier • KeywordsLanguageLastModifiedByLastPrintedRevisionSubjectTitleVersion Common Package Parts Core Properties XPS Package Relationships 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 supportcore properties

  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. Recommended Parts Common Package Parts Core Properties Signed Parts X509 Cert Signature Signature Origin Resources XPS Package Relationships Relationship Signature URI Reference X509 Cert Signed part Signed part Signed part Signed part Digital SignaturesModel • Signature Origin part is the root of all signatures in the package • Each signature located in its own part

  17. Digital SignaturesAPIs • 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 inthe signature • Verify the signature • Verify the signature certificate PackageDigitalSignature PackageDigitalSignatureManager

  18. Digital Signatures

  19. RM Licenses RM Licenses OLE Property Storage Core Properties Common Package Parts Core Properties X509 Cert Signature Signature Origin XPS Package Relationships RM “envelope” Signature X509 Cert Signed part Signed part Signed part 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. Custom File Formats

  21. Custom File FormatsCreating your own • Microsoft encourages applications to adoptthe packaging model for file management • WinFX APIs make this easy • Makes building solutions around yourapplication easier • Factor your data • Decide how to split your application’s databetween parts • Use XML parts to store data that can berepresented textually • Use binary parts to store other data • For XML parts, define your own namespace

  22. Custom File FormatsMore 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 metadatapart to other parts (particularly binary parts) • Take advantage of common package services • E.g. core properties, digital signatures

  23. XPS Document Implementation

  24. XPS DocumentParts 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. Required or Recommended Parts Common Package Parts Core Properties Thumbnail Optional Parts X509 Cert Signature Signature Origin Resources Relationship All parts signed URI Reference Fixed Payload Parts FixedDocumentSequence XPS Package Relationships DocumentStructure FixedDocument Thumbnail FixedPage Font Fonts & Images FixedPage Thumbnail XPS Document Format

  26. XPS DocumentsSolution 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 XpsDocument IDocumentSequenceReader IDocumentSequenceWriter IFixedDocumentReader IFixedDocumentWriter IFixedPageReader IFixedPageWriter

  27. XPS DocumentsAPI 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. XPS DocumentExtensibility • XPS Documents may be extended through the use of markup compatibility • Identical to Windows Presentation Foundation (XAML) markup compatibility • Designed to support backward andforward compatibility • The only proper way to add new features intermixed with XPS Document markup • XPS Viewer will reject files with unknown markup

  29. XPS DocumentMarkup compatibility • XML parts are processed for compatibilityduring 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. XPS DocumentMarkup compatibility sample • <FixedPage Height="1056" Width="816" xml:lang="en-US" • xmlns="http://schemas.microsoft.com/xps/2005/06" • xmlns:mc="http://schemas.microsoft.com/winfx/markup-compatibility/2005" • xmlns:mcext="http://schemas.example.com/PDC/example/extension1" • mc:Ignorable="mcext" > • <Path Stroke="#000000" • Data="M 20,70 A 50,50 0 1 1 120,70 A 50,50 0 1 1 20,70 Z" /> • <mc:AlternateContent> • <mc:Choice Requires=“mcext"> • <Path • mcext:Finish="GoldVarnish" • Data="M 20,70 A 50,50 0 1 1 120,70 A 50,50 0 1 1 20,70 Z" /> • </mc:Choice> • <mc:Fallback> • <Path • Fill="#C8C800" • Opacity="0.2" • Data="M 20,70 A 50,50 0 1 1 120,70 A 50,50 0 1 1 20,70 Z" /> • </mc:Fallback> • </mc:AlternateContent> • </FixedPage>

  31. Conclusion

  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 suiteof technologies

  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. © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

  35. Appendix: Digital SignaturesSample 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<Uri> toSign = new List<Uri>(); foreach (PackagePart packagePart in package.GetParts()) { 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. Appendix: Core Properties Markup sample <CoreProperties xmlns=“http://schemas.microsoft.com/package/2005/06/metadata/core-properties”> <Creator>Jesse McGatha</Creator> <Title>PDC Presentation</Title> <Subject>XML File Formats</Subject> <Category>Presentation</Category> <Keywords>XML;XPS;Office;Format</Keywords> <Description>PDC presentation on XML file formats.</Description> <ContentType>Presentation</ContentType> <ContentStatus>Final</ContentStatus> <Version>1.0</Version> <Revision>231</Revision> <DateCreated>07/21/2005 10:00:00</DateCreated> <DateModified>07/22/2005 12:00:00</DateModified> <LastModifiedBy>Jesse McGatha</LastModifiedBy> <LastPrinted>07/22/2005 12:00:00</LastPrinted> <Language>EN-US</Language> <Identifier>DAT011</Identifier> </CoreProperties>

More Related