windows print spooler (desktop) printer drivers windows runtime html5xaml direct2d windows style app...

35

Upload: irma-fitzgerald

Post on 19-Dec-2015

243 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document
Page 2: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

Justin HutchingsSenior Program ManagerOperating Systems Group

Developing apps and devices that print in Windows 10 and Windows 10 Mobile

2-94

Page 3: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

• Windows print architecture in Windows 10• Developing apps that print• Developing printers that work with

Windows 10 Mobile

Agenda

Page 4: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

Windows Print Spooler (Desktop)

Printer Drivers

Windows print architecture

Windows Runtime

HTML5 XAML

Direct2D

Windows Style App

Windows Print Spooler (Desktop)

XPS Print Document Package Target API

Windows Print Job Manager (Mobile)

Printer Drivers

Print API App rendering API

Print Manager

Print Dialog

Page 5: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

Windows 10 vs Windows 10 Mobile Supported connection types

Setup Supported printers Apps

Windows 10

USB, Network, Shared, “Virtual”

Installed ahead of time

Any printer which has a printer driver available

Windows AppsWindows 8 AppsWin32etc.

Windows 10 Mobile

Network Installed on demand• Supported printers

work automatically• Unsupported

printers not shown

Only Windows 10 Mobile compatible printers• Must support WS-

Print protocol• Must support a

standard PDL

Windows Apps

Page 6: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

• More than 1900 printers supported • Many popular brands supported• Details will be available closer to Windows 10

general availability• More printers will be available in fall ‘15

• Built-in support for saving as PDF

Windows 10 Mobile supported printers

Page 7: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

Demo

Page 8: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

Developing apps that print

Page 9: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

• Printing supported on Windows 10 and Windows 10 Mobile

• Printing is not currently supported on Xbox

• Printing not available in legacy Windows Phone apps

Windows Apps

Build once and run everywhere

Page 10: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

• Charm-based print entry point removed• Mitigation: Your app must include a print button. Print button should

only be active/visible if the app is currently able to print.

• Print API is published for all Windows platforms• Mitigation: Your app must fail gracefully if printing is not currently

supported. Surround all calls to PrintManager.ShowPrintUIAsync() with a try/catch block.

Changes from Windows 8.1 to Windows 10

Page 11: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

Sample: What we’ll cover…

Windows Runtime

HTML5 XAML

Direct2D

Windows Style App

Windows Print Spooler (Desktop)

XPS Print Document Package Target API

Windows Print Job Manager (Mobile)

Printer Drivers

Print API App rendering API

Print Manager

Print Dialog

Page 12: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

AppPrint Manager Print DialogPrintDocument User

PrintTaskRequested += PrintTaskRequestedHandler

Click Print Button

ShowPrintUIAsync()

PrintTaskRequestedHandler()

PrintTask (+= PrintTaskSourceRequestedHandler)

PrintTaskSourceRequestedHandler()

<<create>>

<<return>>

PrintDocument

1. Register for PrintTaskRequested

2. Show print button3. Call ShowPrintUIAsync()4. Handle

PrintTaskRequested and provide PrintTaskSourceRequested

5. Handle PrintTaskSourceRequested by providing an IPrintDocumentSource (property of PrintDocument for XAML apps)

XAML registration, showing the print dialog

Page 13: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

void registerForPrinting(){ //Register for PrintTaskRequested event PrintManager PrintManager = PrintManager.GetForCurrentView(); PrintManager.PrintTaskRequested += PrintManager_PrintTaskRequested;

//Build a PrintDocument and register for callbacks this.Document = new PrintDocument(); this.Document.Paginate += Paginate; this.Document.GetPreviewPage += GetPreviewPage; this.Document.AddPages += AddPages;}

Register for printing

Page 14: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

void PrintManager_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args){ // Create the PrintTask. // Defines the title and delegate for PrintTaskSourceRequested PrintTask printTask = args.Request.CreatePrintTask("Print Job Title", PrintTaskSourceRequested); // Handle PrintTask.Completed to catch failed print jobs printTask.Completed += PrintTaskCompleted; // Configure app specific features for print dialog configurePrintTaskOptionDetails(printTask);}

PrintTaskRequested

Page 15: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

void configurePrintTaskOptionDetails(PrintTask printTask){ PrintTaskOptionDetails details = PrintTaskOptionDetails.GetFromPrintTaskOptions(printTask.Options); IList<string> displayedOptions = details.DisplayedOptions;

// Create a new list option PrintCustomItemListOptionDetails fit = details.CreateItemListOption("Fit", "Fit to Page"); fit.AddItem("Scale", "Scale to Fit"); fit.AddItem("Crop", "Crop to Fit");

// Add the custom option to the option list, handle changes displayedOptions.Add("Fit"); details.OptionChanged += details_OptionChanged;}

Configure custom features

Page 16: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

void PrintTaskSourceRequested(PrintTaskSourceRequestedArgs args){ // Set the document source. This should be initialized in // advance due to short timeouts for this event. args.SetSource(this.Document.DocumentSource);}

PrintTaskSourceRequested

Page 17: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

XAML print previewAppPrint Manager Print DialogPrintDocument User

Click Print Button

ShowPrintUIAsync()

<<create>>

GetPrintPreviewPages

IDocumentPageSource.GetPreviewPageCollection()

<<return>>

IPrintPreviewPageCollection.Paginate

PrintDocument.PaginateEventHandler()

<<return>>

<<return>>

<<return>>

<<return>>

IPrintPreviewPageCollection.MakePage()

PrintDocument.GetPreviewPageEventHandler()

<<return>>

<<return>>

Registration/callbacks omitted

Loop

1. PrintDocument receives all IDocumentSource, IDocumentPageSource and IPrintPreviewPage calls from PrintManager

2. PrintDocument calls Paginate handler

3. Foreach page returned by Paginate handler, PrintDocument calls GetPreviewPage handler

Page 18: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

void Paginate(object sender, PaginateEventArgs e){ // Fired every time that the PrintTaskOptions change // PaginateEventArgs has a copy of current PrintTaskOptions

// Do any necessary work to determine how many // pages are in the printable content // then set the page count. this.Document.SetPreviewPageCount(this.Pages.Count,

PreviewPageCountType.Final);}

Paginate

Page 19: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

void GetPreviewPage(object sender, GetPreviewPageEventArgs e){ // Provide a UIElement as the print preview. // Keep in mind the 1-based indexing for print page numbers int zeroBasedPageNumber = e.PageNumber - 1; this.Document.SetPreviewPage(e.PageNumber,

this.Pages[zeroBasedPageNumber].Image as UIElement);}

GetPreviewPage

Page 20: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

XAML page renderingAppPrint Manager Print DialogPrintDocument User

Change app-specific option

Click Print Button

StartPrintJob

PrintTaskOptionDetails.OptionChangedHandler()

IDocumentPageSource.MakeDocument()

<<return>>

<<return>>

PrintDocument.AddPagesEventHandler()

PrintTaskCompletedEventHandler()

<<return>>

Registration/print preview interactions omitted

1. If custom options exist, OptionChanged handler may be invoked

2. Otherwise, when user clicks print, PrintDocument receives the MakeDocument call.

3. PrintDocument then calls AddPages handler.

4. PrintTaskCompleted event fired to indicate success/failure

Page 21: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

void details_OptionChanged(PrintTaskOptionDetails sender, PrintTaskOptionChangedEventArgs args){ // Find out what option changed if (args.OptionId != null && args.OptionId.ToString() == "Fit") { IPrintOptionDetails fit = sender.Options[args.OptionId.ToString()]; switch (fit.Value.ToString()) { // Handle selected option cases here } }}

OptionChanged

Page 22: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

async void AddPages(object sender, AddPagesEventArgs e){ //Loop through pages to print and add to PrintDocument for (int pageNum = 0; pageNum < this.Pages.Count; pageNum++) { var pageDesc = e.PrintTaskOptions.GetPageDescription((uint)pageNum); var currentPage = this.Pages[pageNum];

// Render UIElement in target resolution; DIP = 1/96” this.Document.AddPage(await currentPage.GetPageInTargetResolution(

(pageDesc.ImageableRect.Width*DpiX)/96),(pageDesc.ImageableRect.Height*DpiY)/96));

} this.Document.AddPagesComplete();}

AddPages

Page 23: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

void PrintTaskCompleted(PrintTask sender, PrintTaskCompletedEventArgs args){ if (args.Completion == PrintTaskCompletion.Failed) { // Notify the user in UI Windows.UI.Popups.MessageDialog md = new

Windows.UI.Popups.MessageDialog("Printing failed."); md.ShowAsync(); }}

PrintTaskCompleted

Page 24: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

• Update your Windows 8/8.1 apps to Windows Apps• Place your own print button in the UI• Catch exceptions around ShowPrintUIAsync() in case your app is

running on a platform without printing

• Test on Windows 10 and on Windows 10 Mobile. • Report any problems you find using the MSDN forums or the Windows

Feedback app. https://social.msdn.microsoft.com/Forums/windowsapps/en-US/home

App developer call to action

Page 25: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

Designing printers for Windows 10 and Windows 10 Mobile

Page 26: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

Windows 10 support for industry standardsStandard Windows 10 Windows 10 Mobile

OpenXPS (ECMA-388) ✓ ✓

PWG Raster (PWG-5102.4-2012) ✓ ✓

PCLm (WFA WFDS-Print) ✓

Page 27: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

Support at least one communication protocol WS-Print v1.x WS-Print v2.0

Support at least one standard PDLPWG Raster (PWG-5102.4-2012)PCLm (WFA WFDS-Print)OpenXPS (ECMA-388)MS XPS

Support discoveryNew devices: Add “MobilePrinter” to WS-Discovery categories; describe

supported PDL in WS-Print Formats elementExisting devices: Contact [email protected] for more information

Windows 10 Mobile printer requirements

Page 28: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

• Mobile compatible printers automatically supported on desktop with class drivers• PCLm-only printers still require a 3rd party driver

• Support for WS-Print 2.0 additionally enables:• Custom Features/Options• Localized Feature/Option names• Custom Bidi status, queries

Mobile compatible printers on desktop

Page 29: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

• Allows printers to expose additional device features without a driver

• Superset of WS-Print v1.0 plus new operations:• PrepareToPrint – Informational operation which allows printers to warm

up• CreatePrintJob2 – Extension of CreatePrintJob including PrintSchema

PrintTicket• GetPrintDeviceCapabilities – Allows retrieval of a

PrintDeviceCapabilities document• GetPrintDeviceResources – Allows retrieval of localized resources in

ResX• GetBidiSchemaExtensions – Allows retrieval of Bidi Schema extensions

WS-Print v2.0

Page 30: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

• OpenXPS• Benefits: Full fidelity vector encoding, smallest spool file size• Drawbacks: Parsing can be memory intensive• Best for: Enterprise-class devices

• PWG Raster• Benefits: Low processing overhead, page processing intent built into

PDL• Drawbacks: Large spool file size can cause slow printouts• Best for: Inkjets, low cost laser devices

• PCLm• Benefits: Proper subset of PDF using only raster, smaller PDL than PWG

Raster• Drawbacks: No built-in page processing intent, no MS class driver for

Windows 10• Best for: Product lines with PDF processing already available

What PDL should I implement?

Page 31: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

...

<psk:JobDuplexAllDocumentsContiguously psf2:psftype="Feature">

<psk:OneSided psf2:psftype="Option" psf2:default="true"/>

<psk:TwoSidedLongEdge psf2:psftype="Option"/>

<psk:TwoSidedShortEdge psf2:psftype="Option"/>

</psk:JobDuplexAllDocumentsContiguously>

<psf2:InvalidCombination>

<psf2:InvalidCombinationEntry psf2:feature="psk:PageMediaType" psf2:option="psk:Transparency"/>

<psf2:InvalidCombinationEntry psf2:feature="psk:JobDuplexAllDocumentsContiguously"

psf2:option="psk:TwoSidedLongEdge"/>

</psf2:InvalidCombination>

<psf2:DocumentFormatOptions>

<psf2:PwgRasterBacksideTumble psf2:DuplexType="psk:TwoSidedShortEdge">

true

</psf2:PwgRasterBacksideTumble>

<psf2:PwgRasterBacksideTumble psf2:DuplexType="psk:TwoSidedLongEdge">

false

</psf2:PwgRasterBacksideTumble>

<psf2:DuplexPageOrder>Standard</psf2:DuplexPageOrder>

<psf2:PwgRasterDocumentTypesSupported>

<psf2:PwgRasterDocumentType psf2:PageOutputColor="psk:Color">

Srgb_8

</psf2:PwgRasterDocumentType>

...

PrintDeviceCapabilities format

New PrintSchema document type used to generate PrintCapabilities and PrintTicket.

Includes simple constraints and options for PWG Raster consumers.

Page 32: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

<?xml version="1.0" encoding="utf-8"?><root xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<data name="schemas.contoso.com/2014/printschema/Main"> <value>Main paper tray</value> </data>

</root>

ResX format

ResX used to localize custom features and options.

Windows 10 will retrieve ResX from WS-Print v2.0 devices. Devices can optionally redirect to a remote URL.

Page 33: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

• Add support for Windows 10 Mobile• Choose one or more standard PDLs: PWG Raster, PCLm, OpenXPS or MS

XPS and build them into your printers• Add support for the MobilePrinter category in WS-Discovery• Update your WS-Print implementation to describe the PDL(s) that you

support• Add support for WS-Print v2.0 to enable a richer feature set• Test your printers against the new Hardware Lab Kit to ensure

compatibility

• If you have existing printers which support our standards• Contact [email protected] for information about including support

for these

Printer IHV Call to Action

Page 34: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

• Whitepapers and specifications• Developing printers that support Windows 10 Mobile• Print Schema Specification v2.0• WSD Print Service Specification v2.0• v4 Print Driver Improvements in Windows 10• Device Profile For Web Services Location Extension

For More Information

Page 35: Windows Print Spooler (Desktop) Printer Drivers Windows Runtime HTML5XAML Direct2D Windows Style App Windows Print Spooler (Desktop) XPS Print Document

© 2015 Microsoft Corporation. All rights reserved.