Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

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

2 Overview Windows Presentation Foundation Document Technologies Open Document Specifications Open packaging conventions XML Paper Specification (XPS) Document Workflows Windows Workflow Foundation (WWF) and Document Workflow Activities Package Workflow Activities XPS Documents Workflow Activities Document Activities and WWF (Demo)

3 New Document Technologies Open 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

4 Open Document Specifications Open Packaging Conventions (Package) Defines conventions for using URI, XML, and Unicode to store content and resources Defines common services for any document: Digital Signatures, Core Properties Defines mapping Package to ZIP archive XML Paper Specification Uses the Open Packaging Conventions Fixed-layout, archivable “Electronic Paper” Specifies markup that is compatible with XAML Native Windows Presentation Foundation print output New spool file added to Windows Vista print architecture

5 Windows Presentation Foundation (WPF) Document APIs Scenario API Support Application includes viewer control that displays XPS pages and WPF content Use Custom Viewer Activity or application opens package and reads/changes/adds parts and relationships, Digital Signatures and Metadata Create/Use Package Application/activity easily creates XPS file from WPF elements Serialize WPF content to XPS Workflow activity or desktop application edits or creates XPS Documents; includes support for Package services for XPS Documents Create/Use XPS Documents Application interacts with Windows RMS to create or consume Open Packaging Convention documents with restricted permissions Create/Use Documents w/ Restricted Permissions

6 Shared Package Office "12" and XPS Documents share: Open packaging conventions (package) Common services in the specification: DigSig, Core Properties Services built to work with package: Rights Management ISVs, IT pros and web applications developers can use the same package Use WPF Document APIs Create packages directly using of the shelf ZIP and XML tools Goal: Reduce code/effort required to manage multiple document types

7 Windows Workflow Foundation And Document Activities

8 Windows Workflow Foundation Extensible framework and tools for building workflow into Windows applications Common workflow technology for Microsoft products, ISVs and customer solutions A framework to build on – not a server or application Key features Unified model for human and system workflow Extensible activity framework Allows workflows to run in any application or server Visual designer for graphical and code-based authoring Availability Availability Included in WinFX Runtime – powers Office12 workflow

9 Windows Workflow Foundation Workflows are a set of activities Activities are the building blocks Tasks are human activities Workflows run within a Host Process: any application or server Developers can build their own Custom Activity Libraries Host Process Windows Workflow Foundation Runtime Engine A Workflow An Activity Runtime Services Base Activity Library Custom Activity Library Visual Designer

10 Office Activity Examples Workflow Workflow History Entry Audit Entry Task Management Create Task Complete task On Task Change Out of Box Tasks Review Task Approval Task Client side scrub task Item Update Item Copy/Delete Item On Item Change Document Sent to Official File Get Range (XL Server) Translate Document Web Send Create alert Validate User Rights Request permissions Front Page Only Calculator Action Create Random Number Render ASPX Page to HTML Assign Survey Task

11 Automating Workflow Activities Access & Modify Content Add Custom Data New WPF document APIs give automated workflow activities transparent access to document protection, content and resources These APIs allow you to create activities that automate and reduce human task load Digital Signatures Control Access & Permissions

12 Package Workflow Activities

13 Package Utility

14 Using Parts and Relationships Activities that modify content need structured access to the content of the document The open packaging conventions of parts and relationships unify how activities can find or add content OFF304 Office Open XML Formats: Enabling Solutions.xlsx XPS Package 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 DAT304 XPS-Based File Formats for Your Application.xps Relationships

15 Packaging APIs System.IO.Packaging 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

16 Finding the Thumbnail (See Demo Code) 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 relatEnum = relationships.GetEnumerator(); IEnumerator 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; }

17 Working with Core Properties Core Properties are stored in a specific part Core Properties are available in: XPS Viewer (View XPS Documents only) Windows UI (View/change) Office Applications (View/change for Office “12” Documents) Category Content Status ContentType Creator DateCreated DateModified Description Identifier Keywords Language LastModifiedBy LastPrinted Revision Subject Title Version Core Properties

18 Package-level Core Properties (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();}

19 Digital Signatures Digital signatures can allow activities to verify that a document: Came from a traceable source The signed content hasn’t changed Package Digital Signature APIs work with collections of parts, relationships, and custom objects embedded in signature Get, set, or clear a signature Validate a signature Get the list of parts, relationships and objects signed Verify the signature certificate System.IO.Packaging / PackageDigitalSignature Use standard XMLDigSig definitions and x509 certificates

20 Digital Signatures Policy Applications (Word, XPS Viewer) validate a signature according to a specific policy Adding new relationships or parts may break signature, depending on policy Activities can also define simple policies for use within the workflow “Sign all parts and relationships before archiving”

21 Control Access & Permissions Package Rights Management APIs allow activities to define who has which permissions to packaged documents as the workflow progresses Systems.IO.Packaging / EncryptedPackage APIs depend on Windows RMS V1 SP1 SDK System.Securitry.RightsManagement / UnsignedPublishLicense Office “12” and XPS Documents support Read, Print, Copy, Full Control Each permission may have an expiration date

22 Example Package Activities Access Activities Extract content Add custom data Merge custom data (“mailmerge”) Find documents by Keyword/Core Property value Get/Set Core Property value Digital Signatures Sign Sign With Policy Verify Signature Validate Certificate Rights Management Open Rights Managed Document Grant Permissions by User Get/Set Core Property value Rights Managed

23 XPS Documents Workflow Activities

24 Scanning to XPS Document

25 OCR Scanned XPS Document

26 XPS Documents (.xps in Beta2) provide additional services for automated workflow activities Access contentAccess content OutputOutput Document assemblyDocument assembly Round-trip signatureRound-trip signature ArchiveArchive XPS Document Workflow Activities.xps

27 Accessing XPS Document Content XPS Document APIs provide additional support for activities that work with XPS Documents (.xps) Fixed Documents/Fixed Pages Fonts, Images, Thumbnails Systems.Windows.Xps.Packaging Optional XPS Document structure links related story fragments Systems.Windows.Documents.DocumentStructure

28 Output XPS Documents Knowledge workers create XPS Documents from any Windows application by printing to the Microsoft XPS Document Writer (MXDW) print driver Driver starts XPS Viewer to define permissions, signatures Win32 applications can create XPS Documents by using MXDW in DevMode

29 XAML Output to XPS PRSHOL12-WinFX Printing and Archiving WPF applications can create.xps output directly from arbitrary XAML content Example creates.xps from flow (Ex. 3, Task 1-3) System.Printing.PrintSubSystem / XPSDocumentWriter 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, FileMode.Create); _containerPackage = Package.Open(fileName, 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(); }

30 Output to Other Formats Developers can add support for third party serializers that convert WPF classes to another format Serializers are installed as full-trust applications Installed serializers can access any WPF class APIs supports enumerating and invoking installed serializers Enumeration includes XpsDocumentWriter System.Windows.Documents.Serialization (Beta 2)

31 XPS Document Signature Policies XPS Document signatures define policies to exclude specific parts, allowing users to Change Core Properties Add a new Signature Add Annotations (reserved for future) XPS Viewer will warn users of changes that may break signature

32 Signing an XPS Document PRSHOL11-Programming XPS Documents Defined policy makes signing.xps easy Example signs.xps with no exclusions (Exercise 4, Task 1-3) Systems.Windows.Xps.Packaging / XpsDigitalSignature System.Security.Cryptography.X509Certificates 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); }

33 Multiple Signer Activities XPS Documents can include a signature definition part that defines: Suggested intent of the signature Requested signer Requested “sign-by” date Suggested local Signature spot location System.Windows.Xps.Packaging / XpsSignatureDefinition XPS Viewer will display signature request

34 Example XPS Document Activities Watermark pages Get Page, Image, Thumbnail Get Story Redact (Find string and Replace) Remove content not specified in XPS Document format Print XPS Document Assemble from multiple.xps Sign with XPS Document policy Add signature request

35 Viewing XPS Content XPS Viewer is an integrated WinFX utility Hosted in IE 6, 7 Publish and consume XPS Documents with restricted permissions Digital Signature validate, verify certificates and request signature (Beta2) Loads XPS-specified subset of XAML Refuses to load document containing unknown content in XPS content types Follows XAML markup compatibility rules (Beta2) Non-XPS parts are ignored (Beta2)

36 Building a Custom Viewer PRSHOL27 – Extending the XPS Document Viewing Experience Custom viewers built with DocumentViewer can display any 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();......

37 Document Activities and WWF

38 New Document Opportunities Shared package reduces complexity of managing XPS/Office/3 rd party documents New WPF APIs let you automate content and management tasks to reduce human task load Using XPS Documents is an easy way to assemble, share and archive document content WPF document APIs create new opportunities for customers and partners to create WWF activities for as building blocks for document workflows

39 Community Resources At PDC For more information, go see 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 After PDC If you missed this related session, watch it on the DVD DAT304 – Unleashing the Power of XPS-Based File Formats for Your Application OFF304 – Developing for the Office “12” User Experience XPS related information and Specifications XPS conformance test suite planned for Windows Vista WDK Beta 2 Office Open XML formats Office Preview Site: Brian Jones’s Blog: Office 2003 Reference Schema Information:

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

41 Appendix: Search XPS Indexing services (iFilters) are provided for XAML part content and metadata Extensible to other content in package Windows and Office Server search use same index service Search can be used to collect set of documents with Common or specific core property values Containing words or phrases

42 Appendix: Package-level Signing From 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 toSign = new List (); List toSign = new List (); // 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);} //Sign Collection //Sign Collection dsm.Sign(toSign, cert); dsm.Sign(toSign, cert); p.Close(); p.Close();}

43 class 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 Document

44 Appendix: Assembling.xps XPS Document FixedDocumentSequence allows multiple documents to be rolled-up into a single XPS Document Resulting document is a continuous set of pages One core property definition Signatures not preserved

45 Appendix: Document Assembly 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) {... } {... }


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

Similar presentations


Ads by Google