1 Unleashing The Power Of XPS-Based File Formats For Your Application Jesse McGatha DAT304 Program...
-
Upload
shannon-french -
Category
Documents
-
view
219 -
download
0
description
Transcript of 1 Unleashing The Power Of XPS-Based File Formats For Your Application Jesse McGatha DAT304 Program...
1
Unleashing The Power Of XPS-Based Unleashing The Power Of XPS-Based File Formats For Your ApplicationFile Formats For Your Application
Jesse McGathaJesse McGathaDAT304DAT304Program ManagerProgram ManagerMicrosoft CorporationMicrosoft Corporation
2
Session OutlineSession OutlinePackagesPackages
File Format DefinitionsFile Format DefinitionsDeveloper ScenariosDeveloper ScenariosPackage Overview (Package Overview (DemoDemo))
Package ServicesPackage ServicesCore PropertiesCore PropertiesDigital Signatures (Digital Signatures (DemoDemo))Rights ManagementRights Management
Custom File Formats Custom File Formats Solution DevelopmentSolution Development
XPS ExtensibilityXPS Extensibility
3
Session GoalsSession GoalsUnderstand the basic package architectureUnderstand the basic package architecture
Basic package formatBasic package formatPackage servicesPackage services
Explore different formats built on packagesExplore different formats built on packagesXPS DocumentsXPS DocumentsOffice “12” files (.docx, .pptx, .xlsx)Office “12” files (.docx, .pptx, .xlsx)Custom formatsCustom formats
Understand the benefits of the architectureUnderstand the benefits of the architectureTransparencyTransparencyFlexibilityFlexibilityRobustnessRobustnessReduced sustained engineering costReduced sustained engineering costMany developer opportunitiesMany developer opportunities
4
File Format DefinitionsFile Format DefinitionsXPS: The XML Paper SpecificationXPS: The XML Paper SpecificationPackages: The foundation of many file Packages: The foundation of many file formatsformats
ZIPZIP
Parts and Relationships AbstractionParts and Relationships Abstraction
Custom Custom FormatsFormats
Office “12” Office “12” Open XMLOpen XML Formats Formats
Package ServicesPackage Services
Open Packaging Conventions SpecificationOpen Packaging Conventions Specification
XPS XPS Document Document
FormatFormatXML
Pape
r XM
L Pa
per
Spec
ifica
tioSp
ecifi
catio
nn
5
Package And XPS Package And XPS TechnologiesTechnologiesOpen Packaging Conventions and XML
Paper Specification (XPS) for use by devices and any application on any
platform.
Open Specification
s
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
Developer ScenariosDeveloper Scenarios1.1. Build custom file formatsBuild custom file formats2.2. Access XPS Document and Office “12” content directlyAccess XPS Document and Office “12” content directly3.3. Provide document solutions for XPS Document, Office “12” or Provide document solutions for XPS Document, Office “12” or
custom files custom files
Win
FXW
inFX
APIs
APIs WinFX WinFX
XPS DocumentXPS DocumentAPIAPI
XPS Document
Format
WinFX WinFX Package APIPackage API
ApplicationsApplications
Custom Format
Custom APIs
Office “12” Open XML Formats
7
Packaging ModelPackaging ModelProvides foundation of a file formatProvides foundation of a file format
Described in the Described in the Open Packaging Open Packaging Conventions Specification v0.75Conventions Specification v0.75Usable by any applicationUsable by any applicationMultiple implementations underwayMultiple implementations underway
XPS Document and Office “12” Open XML XPS Document and Office “12” Open XML formatsformats
Built on concepts of Built on concepts of partsparts and and relationshipsrelationships
Parts are streams of data (XML or binary)Parts are streams of data (XML or binary)Relationships describe how parts are Relationships describe how parts are relatedrelated
Stored in a ZIP archiveStored in a ZIP archive
8
Inspecting A Package Inspecting A Package Using ZIP UtilitiesUsing ZIP Utilities
9
Packaging APIs Packaging APIs ClassesClasses
WinFX provides an API to make WinFX provides an API to make package manipulation easypackage manipulation easyAPI is in API is in System.IO.PackagingSystem.IO.Packaging namespacenamespace
Classes of interestClasses of interestPackagePackagePackagePartPackagePartPackagePartCollectionPackagePartCollectionPackageRelationshipPackageRelationshipPackageRelationshipCollectionPackageRelationshipCollectionPackUriHelperPackUriHelperPackWebRequestPackWebRequestPackWebResponsePackWebResponse
10
Packaging APIs Packaging APIs API FunctionalityAPI Functionality
Open and close packagesOpen and close packagesCreate and delete parts and Create and delete parts and relationshipsrelationshipsGet the name, content-type, and Get the name, content-type, and stream for partsstream for partsRead and write part streamsRead and write part streamsGet the ID, type, and target URI for Get the ID, type, and target URI for relationshipsrelationships
11
Packaging APIs Packaging APIs Sample code – read data from packageSample code – read data from package// Open existing package// Open existing packagePackage package = Package.Open(“C:\Temp\PDCfile.docx”, Package package = Package.Open(“C:\Temp\PDCfile.docx”, FileMode.Open);FileMode.Open);
// Find parts based on relationship type// Find parts based on relationship typestring relType = string relType = ““http://schemas.microsoft.com/office/2006/relationships/officeDocumenthttp://schemas.microsoft.com/office/2006/relationships/officeDocument”;”;PackageRelationshipCollection packRels =PackageRelationshipCollection packRels =
package.GetRelationshipsByType(relType);package.GetRelationshipsByType(relType);
// Assuming there is only one relationship of this type// Assuming there is only one relationship of this typeIEnumerator relsEnumerator = packRels.GetEnumerator();IEnumerator relsEnumerator = packRels.GetEnumerator();relsEnumerator.MoveNext();relsEnumerator.MoveNext();PackageRelationship rel = relsEnumerator.Current;PackageRelationship rel = relsEnumerator.Current;
// For this sample, fetch only the first part in this collection// For this sample, fetch only the first part in this collectionPackagePart part = package.GetPart(PackagePart part = package.GetPart(
PackUriHelper.ResolvePartUri(PackUriHelper.ResolvePartUri(new Uri(“/”, UriKind.Relative), new Uri(“/”, UriKind.Relative), rel.TargetURI));rel.TargetURI));
// Get the stream for this part// Get the stream for this partStream partStream = part.GetStream();Stream partStream = part.GetStream();
12
Package ServicesPackage Services
13
Common Package Common Package ServicesServices
WinFX provides APIs for commonWinFX provides APIs for commonpackage servicespackage services
Core PropertiesCore PropertiesDigital SignaturesDigital SignaturesRights ManagementRights Management
14
Core PropertiesCore PropertiesPackage may include a set of metadata in a single Package may include a set of metadata in a single XML part: The XML part: The core propertiescore properties part part
Discovered by a root relationship with a specific Discovered by a root relationship with a specific relationship typerelationship typeUses a specific content typeUses a specific content type
XPS Document and Office “12” files both supportXPS Document and Office “12” files both supportcore propertiescore properties
CategoryCategoryContent StatusContent StatusContentTypeContentTypeCreatorCreatorDateCreatedDateCreatedDateModifiedDateModifiedDescriptionDescriptionIdentifierIdentifier
KeywordsKeywordsLanguageLanguageLastModifiedByLastModifiedByLastPrintedLastPrintedRevisionRevisionSubjectSubjectTitleTitleVersionVersion
CoreCore PropertiesProperties
XPS
Pack
age
XPS
Pack
age
Rela
tions
hips
Rela
tions
hips
Common Package PartsCommon Package Parts
Core Properties
15
Digital SignaturesDigital SignaturesAllow you to validate that the signed Allow you to validate that the signed content has not been tampered withcontent has not been tampered withAvailable for all package-based file formatsAvailable for all package-based file formatsFollow well-known standards:Follow well-known standards:
Compatible with the XML Digital Signature Compatible with the XML Digital Signature standardstandardCertificates follow X509 standardCertificates follow X509 standard
Parts signed are determined by the signing Parts signed are determined by the signing policypolicy
Example: XPS Document policy is to sign all Example: XPS Document policy is to sign all defined parts and relationshipsdefined parts and relationships
Can be extended by the particular formatCan be extended by the particular format
16
Digital SignaturesDigital SignaturesModelModel
Signature Origin part is the root of all Signature Origin part is the root of all signatures in the packagesignatures in the packageEach signature located in its own partEach signature located in its own part
XPS
Pack
age
XPS
Pack
age
Rela
tions
hips
Rela
tions
hips
Common Package PartsCommon Package PartsCore Properties
Signature Origin X509 Cert
SignatureX509 Cert
Signed part Signed part Signed part Signed part
Signature ResourcesResources
Signed PartsSigned Parts
RecommendedRecommendedPartsParts
RelationshipRelationshipURI ReferenceURI Reference
17
Digital SignaturesDigital SignaturesAPIsAPIs
Classes of interestClasses of interest
PackageDigitalSignatureManager:PackageDigitalSignatureManager:Get, add, or remove a signature to/from the Get, add, or remove a signature to/from the packagepackage
PackageDigitalSignaturePackageDigitalSignatureGet the list of parts signed by the signatureGet the list of parts signed by the signatureGet the list of references to signed relationshipsGet the list of references to signed relationshipsGet the list of signed and unsigned objects inGet the list of signed and unsigned objects inthe signaturethe signatureVerify the signatureVerify the signatureVerify the signature certificateVerify the signature certificate
PackageDigitalSignaturePackageDigitalSignaturePackageDigitalSignatureManagerPackageDigitalSignatureManager
18
Digital SignaturesDigital Signatures
19
OLE Property Storage Core Properties
RM “
enve
lope
”RM
“en
velo
pe” RM LicensesRM Licenses
XPS
Pack
age
XPS
Pack
age
Rela
tions
hips
Rela
tions
hips
Common Package PartsCommon Package PartsCore Properties
Signature Origin Signature X509 Cert
SignatureX509 Cert
Signed part Signed part Signed part Signed part
Rights ManagementRights ManagementMay use any RM solutionMay use any RM solution
RM is external to the XPS SpecificationRM is external to the XPS SpecificationWindows RMS solution provided with WinFXWindows RMS solution provided with WinFX
Allows easy participation in RMS document workflowsAllows easy participation in RMS document workflowsAPI wraps the unmanaged RMS APIAPI wraps the unmanaged RMS API
In the In the System.Security.RightsManagementSystem.Security.RightsManagement namespace namespace
20
Custom File FormatsCustom File Formats
21
Custom File FormatsCustom File FormatsCreating your ownCreating your own
Microsoft encourages applications to adoptMicrosoft encourages applications to adoptthe packaging model for file managementthe packaging model for file management
WinFX APIs make this easyWinFX APIs make this easyMakes building solutions around yourMakes building solutions around yourapplication easierapplication easier
Factor your dataFactor your dataDecide how to split your application’s dataDecide how to split your application’s databetween partsbetween partsUse XML parts to store data that can beUse XML parts to store data that can berepresented textuallyrepresented textuallyUse binary parts to store other dataUse binary parts to store other dataFor XML parts, define your own namespaceFor XML parts, define your own namespace
22
Custom File FormatsCustom File FormatsMore on creating your ownMore on creating your own
Make use of relationshipsMake use of relationshipsDefine your own relationship typesDefine your own relationship typesPrefer relationships over inline URI Prefer relationships over inline URI referencesreferencesThey are a great way to attach a metadataThey are a great way to attach a metadatapart to other parts (particularly binary part to other parts (particularly binary parts)parts)
Take advantage of common package Take advantage of common package services services
E.g. core properties, digital signaturesE.g. core properties, digital signatures
23
XPS Document XPS Document ImplementationImplementation
24
XPS DocumentXPS DocumentParts and relationshipsParts and relationships
Key XPS Document partsKey XPS Document partsFixedDocumentSequenceFixedDocumentSequence – Root of the document– Root of the documentFixedDocumentFixedDocument – Document XML markup– Document XML markupFixedPageFixedPage – Page XML markup– Page XML markupFontFont – Embedded font– Embedded fontImageImage – Embedded image– Embedded imageThumbnailThumbnail – Page thumbnail images– Page thumbnail imagesPrintTicketPrintTicket – Printer settings for – Printer settings for page/documentpage/documentDocumentStructureDocumentStructure – Semantic structure of – Semantic structure of documentdocumentStoryFragmentsStoryFragments – Semantic structure of – Semantic structure of pagepage
Key XPS Document relationshipsKey XPS Document relationshipsStartPartStartPart – Points to the – Points to the FixedDocumentSeq.FixedDocumentSeq.RequiredResourceRequiredResource – Image/font needed to – Image/font needed to render pagerender pagePrintTicketPrintTicket – Printer settings– Printer settings
25
XPS Document FormatXPS Document FormatXP
S Pa
ckag
eXP
S Pa
ckag
eRe
latio
nshi
psRe
latio
nshi
ps
Common Package PartsCommon Package PartsCore Properties
Thumbnail
Signature Origin Signature X509 Cert
Fixed Payload PartsFixed Payload PartsFixedDocumentSequence
FixedDocument
FixedPage
FixedPage
DocumentStructure
FontFonts & Images
Thumbnail
Thumbnail
All parts signedAll parts signed
ResourcesResources
OptionalOptionalPartsParts
Required orRequired orRecommendedRecommendedPartsParts
RelationshipRelationshipURI ReferenceURI Reference
26
XPS DocumentsXPS DocumentsSolution development APIsSolution development APIs
Supersede package APIs for XPS Document Supersede package APIs for XPS Document solutionssolutions
Create, consume, and service XPS DocumentsCreate, consume, and service XPS DocumentsTailored to the specific needs of XPS DocumentsTailored to the specific needs of XPS Documents
API is in API is in System.Windows.Xps.Packaging System.Windows.Xps.Packaging namespace namespace Classes of interestClasses of interestXpsDocumentXpsDocumentIDocumentSequenceReaderIDocumentSequenceReaderIDocumentSequenceWriterIDocumentSequenceWriterIFixedDocumentReaderIFixedDocumentReaderIFixedDocumentWriterIFixedDocumentWriterIFixedPageReaderIFixedPageReaderIFixedPageWriterIFixedPageWriter
27
XPS DocumentsXPS DocumentsAPI functionalityAPI functionality
Document manipulationDocument manipulationAdd/remove documents to document sequence and pages Add/remove documents to document sequence and pages to documents to documents Retrieve or set core propertiesRetrieve or set core propertiesRetrieve or set thumbnailsRetrieve or set thumbnails
Add page contentAdd page contentE.g. colors, fonts, images, resource dictionariesE.g. colors, fonts, images, resource dictionaries
Retrieve/Set PrintTickets (print job control XML)Retrieve/Set PrintTickets (print job control XML)Digital SignaturesDigital Signatures
Automatically sign according to XPS Document signing Automatically sign according to XPS Document signing policypolicySpecify co-signature requirementsSpecify co-signature requirements
28
XPS DocumentXPS DocumentExtensibilityExtensibility
XPS Documents may be extended XPS Documents may be extended through the use of through the use of markup markup compatibilitycompatibility
Identical to Windows Presentation Identical to Windows Presentation Foundation (XAML) markup compatibilityFoundation (XAML) markup compatibilityDesigned to support backward andDesigned to support backward andforward compatibilityforward compatibility
The only proper way to add new The only proper way to add new features intermixed with XPS features intermixed with XPS Document markup Document markup
XPS Viewer will reject files with unknown XPS Viewer will reject files with unknown markupmarkup
29
XPS DocumentXPS DocumentMarkup compatibilityMarkup compatibility
XML parts are processed for compatibilityXML parts are processed for compatibilityduring loadingduring loadingProcess unknown XML namespaces, Process unknown XML namespaces, elements, and attributeselements, and attributes
By default, unknown elements/attributes trigger By default, unknown elements/attributes trigger errorserrorsIgnorableIgnorable suppresses errors triggered by suppresses errors triggered by elements/attributes in unknown namespaceselements/attributes in unknown namespacesProcessContentProcessContent determines if markup nested determines if markup nested within an ignored element should be processedwithin an ignored element should be processedAlternateContentAlternateContent selects a selects a ChoiceChoice based on based on RequiredRequired namespaces namespacesMustUnderstandMustUnderstand triggers an immediate error triggers an immediate error when an unknown namespace is specifiedwhen an unknown namespace is specified
30
XPS DocumentXPS DocumentMarkup compatibility sampleMarkup compatibility sample
<FixedPage Height="1056" Width="816" xml:lang="en-US"<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:mcxmlns:mc="http://schemas.microsoft.com/winfx/markup-compatibility/2005"="http://schemas.microsoft.com/winfx/markup-compatibility/2005" xmlns:mcextxmlns:mcext="http://schemas.example.com/PDC/example/extension1"="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" />
<mc:AlternateContent><mc:AlternateContent> <mc:Choice Requires=“mcext"><mc:Choice Requires=“mcext"> <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" /> </mc:Choice></mc:Choice> <mc:Fallback><mc:Fallback> <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" /> </mc:Fallback></mc:Fallback> </mc:AlternateContent></mc:AlternateContent></FixedPage></FixedPage>
31
ConclusionConclusion
32
BenefitsBenefitsTransparencyTransparency
Really seeReally see what is in your files what is in your filesGreat for archiving – you don’t need particular applicationsGreat for archiving – you don’t need particular applications
FlexibilityFlexibilityFormats are extensible with custom dataFormats are extensible with custom dataFormats can easily be integrated into Formats can easily be integrated into solutionssolutions and and workflowsworkflows
RobustnessRobustnessZIP is recoverableZIP is recoverableCompression benefits file sizeCompression benefits file size
Reduced sustained engineering costsReduced sustained engineering costsUse the WinFX API for managing files rather than a custom Use the WinFX API for managing files rather than a custom APIAPI
Lots of developer opportunitiesLots of developer opportunitiesOpen formats do not require integration of the original Open formats do not require integration of the original application to build a solutionapplication to build a solutionPackages and XPS Documents a broader part of a full suitePackages and XPS Documents a broader part of a full suiteof technologiesof technologies
33
Community ResourcesCommunity ResourcesAt PDCAt PDC
For more information, go seeFor more information, go seePRS333 – Advances in Document Workflow, Securing, Viewing,PRS333 – Advances in Document Workflow, Securing, Viewing,and Printing Your Content and Printing Your Content OFF304 – Developing for the 'Office12' User ExperienceOFF304 – Developing for the 'Office12' User ExperienceOFF415 – Developing Custom Workflows in ‘Office 12’OFF415 – Developing Custom Workflows in ‘Office 12’
Presentation Track LoungePresentation Track LoungeHands on Labs Hands on Labs
PRSHOL27 Extend the XPS Document Viewing ExperiencePRSHOL27 Extend the XPS Document Viewing ExperiencePRSHOL12 WinFX Printing and ArchivingPRSHOL12 WinFX Printing and ArchivingPRSHOL11 Programming XPS DocumentsPRSHOL11 Programming XPS Documents
Package and XPS related information:Package and XPS related information:Specifications: Specifications: http://www.microsoft.com/whdc/xpshttp://www.microsoft.com/whdc/xpsEmail: Email: [email protected]@microsoft.comXPS conformance test suite planned for Windows Vista WDK Beta XPS conformance test suite planned for Windows Vista WDK Beta 22
Office Open XML formatsOffice Open XML formatsOffice Preview Site: Office Preview Site: http://www.microsoft.com/office/preview/ http://www.microsoft.com/office/preview/ Brian Jones’s Blog: Brian Jones’s Blog: http://blogs.msdn.com/Brian_Jones/http://blogs.msdn.com/Brian_Jones/ Office 2003 Reference Schema Information: Office 2003 Reference Schema Information: http://www.microsoft.com/office/xml/ 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 Appendix: Digital SignaturesSignaturesSample codeSample code// Assume // Assume packagepackage contains the Package to sign contains the Package to sign PackageDigitalSignatureManager dsm = new PackageDigitalSignatureManager dsm = new PackageDigitalSignatureManager(package);PackageDigitalSignatureManager(package);
// Get all Parts and add them to the List of Parts to be signed. // Get all Parts and add them to the List of Parts to be signed. // Cannot pass GetParts() enumeration directly as it is// Cannot pass GetParts() enumeration directly as it is// invalidated during Sign process.// invalidated during Sign process.List<Uri> toSign = new List<Uri>();List<Uri> toSign = new List<Uri>();foreach (PackagePart packagePart in package.GetParts())foreach (PackagePart packagePart in package.GetParts()){{ toSign.Add(packagePart.Uri);toSign.Add(packagePart.Uri);}}
// Normally, you wrap this in a try/catch to detect // Normally, you wrap this in a try/catch to detect // when no certificates are available...// when no certificates are available...dsm.Sign(toSign); dsm.Sign(toSign); // Prompt user to select a Cert to sign with// Prompt user to select a Cert to sign with
36
Appendix: Core Properties Appendix: Core Properties Markup sampleMarkup sample<CoreProperties <CoreProperties xmlns=“http://schemas.microsoft.com/package/2005/06/metadata/core-xmlns=“http://schemas.microsoft.com/package/2005/06/metadata/core-properties”>properties”>
<Creator><Creator>Jesse McGathaJesse McGatha</Creator></Creator><Title><Title>PDC PresentationPDC Presentation</Title></Title><Subject><Subject>XML File FormatsXML File Formats</Subject></Subject><Category><Category>PresentationPresentation</Category></Category><Keywords><Keywords>XML;XPS;Office;FormatXML;XPS;Office;Format</Keywords></Keywords><Description><Description>PDC presentation on XML file formats.PDC presentation on XML file formats.</Description></Description><ContentType><ContentType>PresentationPresentation</ContentType></ContentType><ContentStatus><ContentStatus>FinalFinal</ContentStatus></ContentStatus><Version><Version>1.01.0</Version></Version><Revision><Revision>231231</Revision></Revision><DateCreated><DateCreated>07/21/2005 10:00:0007/21/2005 10:00:00</DateCreated></DateCreated><DateModified><DateModified>07/22/2005 12:00:0007/22/2005 12:00:00</DateModified></DateModified><LastModifiedBy><LastModifiedBy>Jesse McGathaJesse McGatha</LastModifiedBy></LastModifiedBy><LastPrinted><LastPrinted>07/22/2005 12:00:0007/22/2005 12:00:00</LastPrinted></LastPrinted><Language><Language>EN-USEN-US</Language></Language><Identifier><Identifier>DAT011DAT011</Identifier></Identifier>
</CoreProperties></CoreProperties>