windows presentation foundation ("avalon"): advances in document workflow automation-...

45
Windows Presentation Foundation Windows Presentation Foundation ("Avalon"): Advances in Document ("Avalon"): Advances in Document Workflow Automation- Securing, Workflow Automation- Securing, Viewing, and Printing Your Content Viewing, and Printing Your Content N. Gregg Brown N. Gregg Brown PRS333 PRS333 Lead Program Manager Lead Program Manager Microsoft Corporation Microsoft Corporation

Upload: christina-crouse

Post on 02-Apr-2015

219 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Windows Presentation Foundation ("Avalon"): Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Advances in Document Workflow Automation- Securing, Viewing, and Printing Your ContentSecuring, Viewing, and Printing Your Content

N. Gregg BrownN. Gregg BrownPRS333PRS333Lead Program ManagerLead Program ManagerMicrosoft CorporationMicrosoft Corporation

Page 2: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

OverviewOverviewWindows Presentation Foundation Windows Presentation Foundation Document TechnologiesDocument Technologies

Open Document SpecificationsOpen Document SpecificationsOpen packaging conventions Open packaging conventions

XML Paper Specification (XPS)XML Paper Specification (XPS)

Document WorkflowsDocument WorkflowsWindows Workflow Foundation (WWF) Windows Workflow Foundation (WWF) and Document Workflow Activitiesand Document Workflow Activities

Package Workflow ActivitiesPackage Workflow Activities

XPS Documents Workflow ActivitiesXPS Documents Workflow Activities

Document Activities and WWF (Demo) Document Activities and WWF (Demo)

Page 3: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

New Document TechnologiesNew Document TechnologiesOpen Packaging Conventions and XML

Paper Specification (XPS) for use by devices and any application on any

platform.

Open Document

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 for “Save

As”

Application programming interfaces (APIs) to manage package and content.

WPF Document

APIs

Print pipeline with XPS spool format and printer-page description language to speed and improve print job fidelity. New driver

model.

XPS Print Path

Page 4: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Open Document Open Document Specifications Specifications Open Packaging Conventions (Package)Open Packaging Conventions (Package)

Defines conventions for using URI, XML, and Defines conventions for using URI, XML, and Unicode to store content and resourcesUnicode to store content and resources

Defines common services for any document: Defines common services for any document: Digital Signatures, Core PropertiesDigital Signatures, Core Properties

Defines mapping Package to ZIP archiveDefines mapping Package to ZIP archive

XML Paper Specification XML Paper Specification Uses the Open Packaging ConventionsUses the Open Packaging Conventions

Fixed-layout, archivable “Electronic Paper”Fixed-layout, archivable “Electronic Paper”Specifies markup that is compatible with XAMLSpecifies markup that is compatible with XAML

Native Windows Presentation Foundation print Native Windows Presentation Foundation print outputoutput

New spool file added to Windows Vista New spool file added to Windows Vista print architectureprint architecture

Page 5: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Windows Presentation Foundation Windows Presentation Foundation (WPF) Document APIs(WPF) Document APIs

ScenarioScenarioAPI SupportAPI Support

Application includes viewer control that Application includes viewer control that displays XPS pages and WPF contentdisplays XPS pages and WPF content

Use Use Custom ViewerCustom Viewer

Activity or application opens package and Activity or application opens package and reads/changes/adds parts and relationships, reads/changes/adds parts and relationships,

Digital Signatures and MetadataDigital Signatures and Metadata

Create/Use Create/Use PackagePackage

Application/activity easily creates XPS file Application/activity easily creates XPS file from WPF elementsfrom WPF elements

Serialize WPF Serialize WPF content to XPScontent to XPS

Workflow activity or desktop application Workflow activity or desktop application edits or creates XPS Documents; includes edits or creates XPS Documents; includes

support for Package services for XPS support for Package services for XPS DocumentsDocuments

Create/Use Create/Use XPS XPS

DocumentsDocuments

Application interacts with Windows RMS to Application interacts with Windows RMS to create or consume Open Packaging create or consume Open Packaging

Convention documents with restricted Convention documents with restricted permissionspermissions

Create/Use Create/Use Documents w/ Documents w/

Restricted Restricted PermissionsPermissions

Page 6: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Shared Package Shared Package Office "12" and XPS Documents Office "12" and XPS Documents share:share:

Open packaging conventions (package)Open packaging conventions (package)Common services in the specification: Common services in the specification: DigSig, Core PropertiesDigSig, Core PropertiesServices built to work with package:Services built to work with package:Rights ManagementRights Management

ISVs, IT pros and web applications ISVs, IT pros and web applications developers can use the same developers can use the same package package

Use WPF Document APIsUse WPF Document APIsCreate packages directly using of the Create packages directly using of the shelf ZIP and XML toolsshelf ZIP and XML tools

Goal: Reduce code/effort required to Goal: Reduce code/effort required to manage multiple document typesmanage multiple document types

Page 7: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Windows Workflow Windows Workflow FoundationFoundationAnd Document ActivitiesAnd Document Activities

Page 8: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Windows Workflow Windows Workflow FoundationFoundationExtensible framework and tools for Extensible framework and tools for building workflow into Windows applicationsbuilding workflow into Windows applicationsCommon workflow technology for Microsoft Common workflow technology for Microsoft

products, ISVs and customer solutionsproducts, ISVs and customer solutions

A framework to build on – not a server or A framework to build on – not a server or applicationapplication

Key featuresKey featuresUnified model for human and system workflowUnified model for human and system workflow

Extensible activity frameworkExtensible activity framework

Allows workflows to run in any application or Allows workflows to run in any application or serverserver

Visual designer for graphical and code-based Visual designer for graphical and code-based authoringauthoring

AvailabilityAvailabilityIncluded in WinFX Runtime – powers Office12 Included in WinFX Runtime – powers Office12 workflowworkflow

Page 9: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Windows Workflow FoundationWindows Workflow Foundation

WorkflowsWorkflows are a set of are a set of activitiesactivities

ActivitiesActivities are the are the building blocksbuilding blocks

TasksTasks are human are human activitiesactivities

Workflows run within a Workflows run within a Host Process: Host Process: any any application or serverapplication or server

Developers can build Developers can build their own their own Custom Custom Activity LibrariesActivity Libraries Host Process

WindowsWindowsWorkflow FoundationWorkflow Foundation

Runtime Engine

A Workflow

An Activity

Runtime Services

Base Activity Library

Custom Activity Library

Visual Designer

Page 10: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Office Activity ExamplesOffice Activity ExamplesWorkflowWorkflow

Workflow History EntryWorkflow History EntryAudit EntryAudit Entry

Task ManagementTask ManagementCreate TaskCreate TaskComplete task Complete task On Task ChangeOn Task Change

Out of Box TasksOut of Box TasksReview TaskReview TaskApproval TaskApproval TaskClient side scrub taskClient side scrub task

ItemItemUpdate ItemUpdate ItemCopy/Delete ItemCopy/Delete ItemOn Item ChangeOn Item Change

DocumentDocumentSent to Official FileSent to Official FileGet Range (XL Server)Get Range (XL Server)Translate DocumentTranslate Document

WebWebSend emailSend emailCreate alertCreate alertValidate User RightsValidate User RightsRequest permissionsRequest permissions

Front Page OnlyFront Page OnlyCalculator ActionCalculator ActionCreate Random NumberCreate Random NumberRender ASPX Page to Render ASPX Page to HTMLHTMLAssign Survey TaskAssign Survey Task

Page 11: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Automating Workflow Automating Workflow ActivitiesActivities

Access & Modify Access & Modify Content Content

Add Add Custom Custom DataData

New WPF document APIs give automated New WPF document APIs give automated workflow activities workflow activities transparent accesstransparent access to to document protection, content and document protection, content and resourcesresources

These APIs allow you to create activities These APIs allow you to create activities that that automate and reduce human task automate and reduce human task loadload

Digital Digital SignaturesSignatures

Control Control Access Access & Permissions & Permissions

Page 12: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Package Workflow ActivitiesPackage Workflow Activities

Page 13: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Package UtilityPackage Utility

Page 14: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Using Parts and Using Parts and Relationships Relationships

Activities that Activities that modify modify content need content need structured structured accessaccess to the to the content of the content of the documentdocumentThe open The open packaging packaging conventions conventions of of parts and parts and relationships relationships unify how unify how activities can activities can find or add find or add contentcontent

Document Properties

Application Properties

Custom Doc. Props.

Workbook

Sheet 2

Sheet 3

Sheet 1 Styles

Chart

Strings

Relationship

...

...

OFF304 Office Open XML Formats: Enabling SolutionsOFF304 Office Open XML Formats: Enabling Solutions

.xls

x

XPS P

ack

age

XPS P

ack

age

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

DAT304 XPS-Based File Formats for Your ApplicationDAT304 XPS-Based File Formats for Your Application

.xps

Rela

tion

ship

sR

ela

tion

ship

s

Page 15: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Packaging APIs Packaging APIs System.IO.PackagingSystem.IO.Packaging

Open and close packagesOpen and close packages

Create and delete parts and Create and delete parts and relationshipsrelationships

Get the name, content-type, and Get the name, content-type, and stream stream for partsfor parts

Read and write part streamsRead and write part streams

Get the ID, type, and target URI for Get the ID, type, and target URI for relationshipsrelationships

Page 16: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Finding the ThumbnailFinding the Thumbnail(See Demo Code)(See Demo Code)

private Image GetThumbnail()private Image GetThumbnail() {{ Package p = Package.Open(_fileName, FileMode.Open, FileAccess.Read);Package p = Package.Open(_fileName, FileMode.Open, FileAccess.Read); //get Thumbnail relationship//get Thumbnail relationship PackageRelationshipCollection relationships = PackageRelationshipCollection relationships = p.GetRelationshipsByType(XpsHelper.PackageThumbnailRelationship);p.GetRelationshipsByType(XpsHelper.PackageThumbnailRelationship); IEnumerator<PackageRelationship> relatEnum = relationships.GetEnumerator();IEnumerator<PackageRelationship> relatEnum = relationships.GetEnumerator(); PackageRelationship relat = relatEnum.Current;PackageRelationship relat = relatEnum.Current;

//get uri of thumbnail pointed to by relationship. //get uri of thumbnail pointed to by relationship. //Assume relationship is not relative to package root//Assume relationship is not relative to package root sourceUri = relat.Source.Uri;sourceUri = relat.Source.Uri; Uri thumbnailUri = PackUriHelper.ResolvePartUri(sourceUri, relat.TargetUri);Uri thumbnailUri = PackUriHelper.ResolvePartUri(sourceUri, relat.TargetUri); PackagePart part = p.GetPart(thumbnailUri);PackagePart part = p.GetPart(thumbnailUri);

//get the image stream and content type//get the image stream and content type imgStream = part.GetStream();imgStream = part.GetStream(); contentType = part.ContentType;contentType = part.ContentType;

// Process the thumbnail stream // Process the thumbnail stream ......

p.Close();p.Close(); return img;return img; }}

Page 17: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Working with Core PropertiesWorking with Core Properties

Core Properties are Core Properties are stored in a specific partstored in a specific part

Core Properties are Core Properties are available in: available in:

XPS Viewer XPS Viewer (View XPS Documents only)(View XPS Documents only)

Windows UI (View/change)Windows UI (View/change)

Office Applications Office Applications (View/change for Office “12” Documents)(View/change for Office “12” Documents)

CategoryContent StatusContentTypeCreatorDateCreatedDateModified DescriptionIdentifier

KeywordsLanguageLastModifiedByLastPrintedRevisionSubjectTitleVersion

Core Properties

Page 18: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Package-level Core Package-level Core PropertiesProperties(See Demo Code)(See Demo Code)

{{ Package p = Package.Open(doc, FileMode.Open, FileAccess.ReadWrite);Package p = Package.Open(doc, FileMode.Open, FileAccess.ReadWrite); p.CoreProperties.Version = "Final";p.CoreProperties.Version = "Final"; p.Close();p.Close();}}

Page 19: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Digital SignaturesDigital Signatures

Digital signatures can allow activities to verify Digital signatures can allow activities to verify that a document:that a document:

Came from a traceable sourceCame from a traceable sourceThe signed content hasn’t changedThe signed content hasn’t changed

Package Digital Signature APIs work with Package Digital Signature APIs work with collections of parts, relationships, and custom collections of parts, relationships, and custom objects embedded in signature objects embedded in signature

Get, set, or clear a signatureGet, set, or clear a signatureValidate a signatureValidate a signatureGet the list of parts, relationships and objects signed Get the list of parts, relationships and objects signed Verify the signature certificateVerify the signature certificate

System.IO.Packaging / PackageDigitalSignatureSystem.IO.Packaging / PackageDigitalSignature

Use standard XMLDigSig definitions Use standard XMLDigSig definitions and x509 certificatesand x509 certificates

Page 20: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Digital Signatures PolicyDigital Signatures Policy

Applications (Word, XPS Viewer) Applications (Word, XPS Viewer) validate a signature according to a validate a signature according to a specific policyspecific policy

Adding new relationships or parts Adding new relationships or parts may break signature, depending on may break signature, depending on policypolicy

ActivitiesActivities can also define simple can also define simple policies for use within the workflowpolicies for use within the workflow

““Sign all parts and relationships Sign all parts and relationships before archiving”before archiving”

Page 21: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Control Access & Control Access & PermissionsPermissions

Package Rights Management APIs Package Rights Management APIs allow activities to define allow activities to define whowho has has whichwhich permissions to packaged permissions to packaged documents as the workflow documents as the workflow progresses progresses Systems.IO.Packaging / EncryptedPackageSystems.IO.Packaging / EncryptedPackage

APIs depend on Windows RMS V1 SP1 APIs depend on Windows RMS V1 SP1 SDKSDK

System.Securitry.RightsManagement / System.Securitry.RightsManagement / UnsignedPublishLicenseUnsignedPublishLicense

Office “12” and XPS Documents Office “12” and XPS Documents support Read, Print, Copy, Full support Read, Print, Copy, Full ControlControl

Each permission may have an Each permission may have an expiration dateexpiration date

Page 22: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Example Package Example Package ActivitiesActivities

Access ActivitiesAccess ActivitiesExtract contentExtract content

Add custom dataAdd custom data

Merge custom data Merge custom data (“mailmerge”)(“mailmerge”)

Find documents by Find documents by Keyword/Core Property Keyword/Core Property valuevalue

Get/Set Core Property Get/Set Core Property valuevalue

Digital SignaturesDigital SignaturesSign Sign

Sign With PolicySign With Policy

Verify SignatureVerify Signature

Validate CertificateValidate Certificate

Rights ManagementRights ManagementOpen Rights Managed Open Rights Managed DocumentDocument

Grant Permissions by Grant Permissions by UserUser

Get/Set Core Property Get/Set Core Property value Rights Managedvalue Rights Managed

Page 23: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

XPS Documents XPS Documents Workflow Activities Workflow Activities

Page 24: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Scanning to XPS DocumentScanning to XPS Document

Page 25: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

OCR Scanned XPS OCR Scanned XPS Document Document

Page 26: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

XPS Documents XPS Documents (.xps in Beta2) (.xps in Beta2) provide provide additional additional services for services for automated automated workflow workflow activitiesactivities• Access contentAccess content• Output Output • Document Document

assemblyassembly• Round-trip Round-trip

signaturesignature• Archive Archive

XPS Document Workflow XPS Document Workflow ActivitiesActivities

.xp.xps s

Page 27: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Accessing XPS Accessing XPS Document ContentDocument Content

XPS Document APIs provide XPS Document APIs provide additional support for activities that additional support for activities that work with XPS Documents (.xps)work with XPS Documents (.xps)

Fixed Documents/Fixed PagesFixed Documents/Fixed Pages

Fonts, Images, ThumbnailsFonts, Images, Thumbnails

Systems.Windows.Xps.PackagingSystems.Windows.Xps.Packaging

Optional XPS Document structure Optional XPS Document structure links related story fragmentslinks related story fragmentsSystems.Windows.Documents.DocumentStructure Systems.Windows.Documents.DocumentStructure

Page 28: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Output XPS DocumentsOutput XPS Documents

Knowledge workers create XPS Knowledge workers create XPS Documents from any Windows Documents from any Windows application by printing to the application by printing to the Microsoft XPS Document Writer Microsoft XPS Document Writer (MXDW) print driver(MXDW) print driver

Driver starts XPS Viewer to define Driver starts XPS Viewer to define permissions, signatures permissions, signatures

Win32 applications can create XPS Win32 applications can create XPS Documents by using MXDW in Documents by using MXDW in DevModeDevMode

Page 29: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

XAML Output to XPSXAML Output to XPSPRSHOL12-WinFX Printing and PRSHOL12-WinFX Printing and ArchivingArchiving

WPF applications can create .xps WPF applications can create .xps output directly from arbitrary XAML output directly from arbitrary XAML contentcontent

Example creates .xps from flow Example creates .xps from flow (Ex. 3, Task 1-3)(Ex. 3, Task 1-3)

System.Printing.PrintSubSystem / XPSDocumentWriterSystem.Printing.PrintSubSystem / XPSDocumentWriter public void ArchiveSingleFlowContentDocument()public void ArchiveSingleFlowContentDocument() {{ IDocumentPaginator idp = _xpfContent.CreateFlowDocument();IDocumentPaginator idp = _xpfContent.CreateFlowDocument(); _containerPackage = null;_containerPackage = null; File.Delete(fileName);File.Delete(fileName); _containerPackage = Package.Open(fileName,_containerPackage = Package.Open(fileName,FileMode.Create);FileMode.Create); XpsDocument xpsDoc = new XpsDocument(_containerPackage);XpsDocument xpsDoc = new XpsDocument(_containerPackage); XpsDocumentWriter xpsdw = XpsDocument.CreateXpsDocumentWriter(xpsDoc);XpsDocumentWriter xpsdw = XpsDocument.CreateXpsDocumentWriter(xpsDoc); xpsdw.Write(idp);xpsdw.Write(idp); _containerPackage.Close();_containerPackage.Close(); }}

Page 30: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Output to Other FormatsOutput to Other Formats

Developers can add support for third Developers can add support for third party serializers that convert WPF party serializers that convert WPF classes to another formatclasses to another format

Serializers are installed as full-trust Serializers are installed as full-trust applicationsapplications

Installed serializers can access any Installed serializers can access any WPF classWPF class

APIs supports enumerating and APIs supports enumerating and invoking installed serializers invoking installed serializers

Enumeration includes Enumeration includes XpsDocumentWriterXpsDocumentWriter

System.Windows.Documents.Serialization System.Windows.Documents.Serialization (Beta 2)(Beta 2)

Page 31: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

XPS Document XPS Document Signature PoliciesSignature Policies

XPS Document signatures define XPS Document signatures define policies to exclude specific parts, policies to exclude specific parts, allowing users to allowing users to

Change Core PropertiesChange Core Properties

Add a new Signature Add a new Signature

Add Annotations (reserved for future)Add Annotations (reserved for future)

XPS Viewer will warn users of XPS Viewer will warn users of changes that may break signaturechanges that may break signature

Page 32: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Signing an XPS DocumentSigning an XPS DocumentPRSHOL11-Programming XPS PRSHOL11-Programming XPS DocumentsDocuments

Defined policy makes signing .xps Defined policy makes signing .xps easyeasy

Example signs .xps with no exclusions Example signs .xps with no exclusions (Exercise 4, Task 1-3)(Exercise 4, Task 1-3)

Systems.Windows.Xps.Packaging / Systems.Windows.Xps.Packaging / XpsDigitalSignatureXpsDigitalSignatureSystem.Security.Cryptography.X509CertificatesSystem.Security.Cryptography.X509Certificates

public static void SignDigitally(string dstContainer, string certFilename)public static void SignDigitally(string dstContainer, string certFilename) {{ XpsDocument document = new XpsDocument(dstContainer,XpsDocument document = new XpsDocument(dstContainer, FileAccess.ReadWrite);FileAccess.ReadWrite); X509Certificate certificate =X509Certificate certificate = X509Certificate.CreateFromCertFile(certFilename);X509Certificate.CreateFromCertFile(certFilename); document.SignDigitally(certificate, true,document.SignDigitally(certificate, true, XpsDigSigPartAlteringRestrictions.None);XpsDigSigPartAlteringRestrictions.None); }}

Page 33: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Multiple Signer ActivitiesMultiple Signer Activities

XPS Documents can include a XPS Documents can include a signature definition part that defines:signature definition part that defines:

Suggested intent of the signatureSuggested intent of the signature

Requested signerRequested signer

Requested “sign-by” dateRequested “sign-by” date

Suggested local Suggested local

Signature spot locationSignature spot locationSystem.Windows.Xps.Packaging / System.Windows.Xps.Packaging / XpsSignatureDefinitionXpsSignatureDefinition

XPS Viewer will display signature XPS Viewer will display signature requestrequest

Page 34: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Example XPS Document ActivitiesExample XPS Document Activities

Watermark pagesWatermark pagesGet Page, Image, ThumbnailGet Page, Image, ThumbnailGet StoryGet StoryRedact (Find string and Replace)Redact (Find string and Replace)Remove content not specified in Remove content not specified in XPS Document formatXPS Document formatPrint XPS DocumentPrint XPS DocumentAssemble from multiple .xpsAssemble from multiple .xpsSign with XPS Document policySign with XPS Document policyAdd signature requestAdd signature request

Page 35: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Viewing XPS ContentViewing XPS ContentXPS Viewer is an integrated WinFX XPS Viewer is an integrated WinFX utility utility

Hosted in IE 6, 7Hosted in IE 6, 7Publish and consume XPS Documents Publish and consume XPS Documents with restricted permissionswith restricted permissionsDigital Signature validate, verify Digital Signature validate, verify certificates and request signature certificates and request signature (Beta2)(Beta2)

Loads XPS-specified subset of XAMLLoads XPS-specified subset of XAMLRefuses to load document containing Refuses to load document containing unknown content in XPS content typesunknown content in XPS content typesFollows XAML markup compatibility rules Follows XAML markup compatibility rules (Beta2) (Beta2) Non-XPS parts are ignored (Beta2)Non-XPS parts are ignored (Beta2)

Page 36: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Building a Custom ViewerBuilding a Custom ViewerPRSHOL27 – Extending the XPS Document PRSHOL27 – Extending the XPS Document

Viewing Experience Viewing Experience

Custom viewers built with Custom viewers built with DocumentViewer can display any DocumentViewer can display any XPS Document (Exercise 4, Task 1-3)XPS Document (Exercise 4, Task 1-3)

...... XpsDocument xpsDoc = new XpsDocument(filename, FileAccess.Read);XpsDocument xpsDoc = new XpsDocument(filename, FileAccess.Read); DocumentViewer docViewer = new DocumentViewer();DocumentViewer docViewer = new DocumentViewer(); docViewer.Document = xpsDoc.GetPackageRoot();docViewer.Document = xpsDoc.GetPackageRoot(); ......

Page 37: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Document Activities and Document Activities and WWF WWF

Page 38: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

New Document New Document OpportunitiesOpportunities

Shared package reduces complexityShared package reduces complexity of managing XPS/Office/3of managing XPS/Office/3rdrd party party documentsdocumentsNew WPF APIs let you New WPF APIs let you automate automate content and management tasks to content and management tasks to reduce human task loadreduce human task loadUsing Using XPS DocumentsXPS Documents is an easy is an easy way to way to assemble, share and archiveassemble, share and archive document contentdocument contentWPF document APIsWPF document APIs create new create new opportunities for customers and opportunities for customers and partners to partners to create WWF activitiescreate WWF activities for for as building blocks for document as building blocks for document workflowsworkflows

Page 39: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Community ResourcesCommunity ResourcesAt PDCAt PDC

For more information, go seeFor more information, go seeOFF415 – 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

After PDCAfter PDCIf you missed this related session, watch it on the DVDIf you missed this related session, watch it on the DVD

DAT304 – Unleashing the Power of XPS-Based File Formats for Your DAT304 – Unleashing the Power of XPS-Based File Formats for Your ApplicationApplicationOFF304 – Developing for the Office “12” User ExperienceOFF304 – Developing for the Office “12” User Experience

XPS related information and SpecificationsXPS related information and Specificationshttp://http://www.microsoft.com/whdc/xpswww.microsoft.com/whdc/xpsEmail: Email: [email protected]@microsoft.comXPS conformance test suite planned for Windows Vista WDK XPS conformance test suite planned for Windows Vista WDK Beta 2Beta 2

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/

Page 40: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

Page 41: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Appendix: Search XPS Appendix: Search XPS

Indexing services (iFilters) are Indexing services (iFilters) are provided for XAML part content and provided for XAML part content and metadatametadata

Extensible to other content in packageExtensible to other content in package

Windows and Office Server search Windows and Office Server search use same index serviceuse same index service

Search can be used to collect set of Search can be used to collect set of documents with documents with

Common or specific core property valuesCommon or specific core property values

Containing words or phrases Containing words or phrases

Page 42: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Appendix: Package-level Appendix: Package-level SigningSigningFrom the DemoFrom the Demo

{{ Package p = Package.Open(doc, FileMode.Open, FileAccess.ReadWrite);Package p = Package.Open(doc, FileMode.Open, FileAccess.ReadWrite); //Create a Digital SIgnature Manager//Create a Digital SIgnature Manager PackageDigitalSignatureManager dsm = new PackageDigitalSignatureManager(p);PackageDigitalSignatureManager dsm = new PackageDigitalSignatureManager(p); // 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>(); // No signing policy defined for XPS Packages, just sign everything// No signing policy defined for XPS Packages, just sign everything foreach (PackagePart packagePart in p.GetParts()) foreach (PackagePart packagePart in p.GetParts())

{{toSign.Add(packagePart.Uri);toSign.Add(packagePart.Uri);} }

//Sign Collection//Sign Collection dsm.Sign(toSign, cert);dsm.Sign(toSign, cert); p.Close();p.Close();}}

Page 43: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

class RmProtectContentclass RmProtectContent {{ ...... //Open xrml file and read xrml data to string xrmlString//Open xrml file and read xrml data to string xrmlString

//Build secure environment//Build secure environment secureEnv = SecureEnvironment.InitSecureEnvironment(_applicationManifest, secureEnv = SecureEnvironment.InitSecureEnvironment(_applicationManifest, new User(_currenUserId, AuthenticationType.Windows));new User(_currenUserId, AuthenticationType.Windows)); //Build UnsignedPublishLicense from xrml string //Build UnsignedPublishLicense from xrml string UnsignedPublishLicense upl = new UnsignedPublishLicense(xrmlString);UnsignedPublishLicense upl = new UnsignedPublishLicense(xrmlString); User author = upl.Owner;User author = upl.Owner;

//Sign the UnsignedPublishLicense to build the PublishLicense//Sign the UnsignedPublishLicense to build the PublishLicense UseLicense authorsUseLicense;UseLicense authorsUseLicense; PublishLicense publishLicense = upl.Sign(secureEnv, out authorsUseLicense);PublishLicense publishLicense = upl.Sign(secureEnv, out authorsUseLicense);

//Bind the author's UseLicnse to get the CryptoProvider //Bind the author's UseLicnse to get the CryptoProvider BindingFailure errorCode;BindingFailure errorCode; CryptoProvider cryptoProvider = authorsUseLicense.Bind(secureEnv, out errorCode);CryptoProvider cryptoProvider = authorsUseLicense.Bind(secureEnv, out errorCode);

//Create a EncryptedPackage object to RM protect the contents //Create a EncryptedPackage object to RM protect the contents Stream packageStream = File.OpenRead(xpsExistingFile);Stream packageStream = File.OpenRead(xpsExistingFile); EncryptedPackage ePackage = EncryptedPackage.CreateFromPackage(xpsNewFile, EncryptedPackage ePackage = EncryptedPackage.CreateFromPackage(xpsNewFile, packageStream, publishLicense, cryptoProvider);packageStream, publishLicense, cryptoProvider);

//Add in a UseLicense for the author //Add in a UseLicense for the author RightsManagementInformation rmi = ePackage.RightsManagementInformation;RightsManagementInformation rmi = ePackage.RightsManagementInformation; rmi.SaveUseLicense(author, authorsUseLicense);rmi.SaveUseLicense(author, authorsUseLicense);

ePackage.Close(); ePackage.Close(); ...... }}

Appendix: Protecting a Appendix: Protecting a DocumentDocument

Page 44: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Appendix: Appendix: Assembling .xpsAssembling .xps

XPS Document XPS Document FixedDocumentSequence allows FixedDocumentSequence allows multiple documents to be rolled-up multiple documents to be rolled-up into a single XPS Documentinto a single XPS DocumentResulting document is a continuous Resulting document is a continuous set of pagesset of pages

One core property definitionOne core property definitionSignatures not preservedSignatures not preserved

Page 45: Windows Presentation Foundation ("Avalon"): Advances in Document Workflow Automation- Securing, Viewing, and Printing Your Content N. Gregg Brown PRS333

Appendix: Document Appendix: Document AssemblyAssembly FixedDocumentSequence MergeXpsDocuments(FixedDocumentSequence[] xpsDocs)FixedDocumentSequence MergeXpsDocuments(FixedDocumentSequence[] xpsDocs)

{{ FixedDocumentSequence docSeqOut = new FixedDocumentSequence();FixedDocumentSequence docSeqOut = new FixedDocumentSequence(); foreach (FixedDocumentSequence ds in xpsDocs)foreach (FixedDocumentSequence ds in xpsDocs) {{ foreach (DocumentReference dr in ds.References)foreach (DocumentReference dr in ds.References) {{ DocumentReference docRef = new DocumentReference();DocumentReference docRef = new DocumentReference(); FixedDocument fixedDoc = new FixedDocument();FixedDocument fixedDoc = new FixedDocument(); foreach (PageContent pc in dr.GetDocument(false).Pages)foreach (PageContent pc in dr.GetDocument(false).Pages) {{ PageContent pageContent = new PageContent();PageContent pageContent = new PageContent(); FixedPage fixedPage = pc.GetPageRoot(false);FixedPage fixedPage = pc.GetPageRoot(false); ((System.Windows.Serialization.IAddChild)pageContent).AddChild(fixedPage);((System.Windows.Serialization.IAddChild)pageContent).AddChild(fixedPage); fixedDoc.Pages.Add(pageContent);fixedDoc.Pages.Add(pageContent); }} docRef.SetDocument(fixedDoc);docRef.SetDocument(fixedDoc); docSeqOut.References.Add(docRef);docSeqOut.References.Add(docRef); }} }} return docSeqOut;return docSeqOut; }}void SaveXpsDocument(Document doc, string fileName)void SaveXpsDocument(Document doc, string fileName) { ... }{ ... }