Presentation is loading. Please wait.

Presentation is loading. Please wait.

2-94 Developing apps and devices that print in Windows 10 and Windows 10 Mobile Justin Hutchings Senior Program Manager Operating Systems Group.

Similar presentations


Presentation on theme: "2-94 Developing apps and devices that print in Windows 10 and Windows 10 Mobile Justin Hutchings Senior Program Manager Operating Systems Group."— Presentation transcript:

1

2 2-94 Developing apps and devices that print in Windows 10 and Windows 10 Mobile Justin Hutchings Senior Program Manager Operating Systems Group

3 Agenda Windows print architecture in Windows 10
Developing apps that print Developing printers that work with Windows 10 Mobile

4 Windows print architecture
XPS Print Document Package Target API Windows print architecture Direct2D Windows Style App Print API App rendering API HTML5 XAML Print Manager Print Dialog Windows Runtime Windows Print Spooler (Desktop) Windows Print Spooler (Desktop) Windows Print Job Manager (Mobile) Printer Drivers Printer Drivers

5 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 Apps Windows 8 Apps Win32 etc. 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

6 Windows 10 Mobile supported printers
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

7 Demo

8 Developing apps that print

9 Build once and run everywhere
Windows Apps Build once and run everywhere Printing supported on Windows 10 and Windows 10 Mobile Printing is not currently supported on Xbox Printing not available in legacy Windows Phone apps

10 Changes from Windows 8.1 to Windows 10
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.

11 Sample: What we’ll cover…
XPS Print Document Package Target API Sample: What we’ll cover… Direct2D Windows Style App Print API App rendering API HTML5 XAML Print Manager Print Dialog Windows Runtime Windows Print Spooler (Desktop) Windows Print Job Manager (Mobile) Printer Drivers

12 XAML registration, showing the print dialog
Register for PrintTaskRequested Show print button Call ShowPrintUIAsync() Handle PrintTaskRequested and provide PrintTaskSourceRequested Handle PrintTaskSourceRequested by providing an IPrintDocumentSource (property of PrintDocument for XAML apps)

13 Register for printing 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; }

14 PrintTaskRequested 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); }

15 Configure custom features
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; }

16 PrintTaskSourceRequested
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); }

17 XAML print preview PrintDocument receives all IDocumentSource, IDocumentPageSource and IPrintPreviewPage calls from PrintManager PrintDocument calls Paginate handler Foreach page returned by Paginate handler, PrintDocument calls GetPreviewPage handler

18 Paginate 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); }

19 GetPreviewPage 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); }

20 XAML page rendering If custom options exist, OptionChanged handler may be invoked Otherwise, when user clicks print, PrintDocument receives the MakeDocument call. PrintDocument then calls AddPages handler. PrintTaskCompleted event fired to indicate success/failure

21 OptionChanged 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 }

22 AddPages 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();

23 PrintTaskCompleted 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(); }

24 App developer call to action
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.

25 Designing printers for Windows 10 and Windows 10 Mobile

26 Windows 10 support for industry standards
Windows 10 Mobile OpenXPS (ECMA-388) PWG Raster (PWG ) PCLm (WFA WFDS-Print)

27 Windows 10 Mobile printer requirements
Support at least one communication protocol WS-Print v1.x WS-Print v2.0 Support at least one standard PDL PWG Raster (PWG ) PCLm (WFA WFDS-Print) OpenXPS (ECMA-388) MS XPS Support discovery New devices: Add “MobilePrinter” to WS-Discovery categories; describe supported PDL in WS-Print Formats element Existing devices: Contact for more information

28 Mobile compatible printers on desktop
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

29 WS-Print v2.0 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

30 What PDL should I implement?
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

31 PrintDeviceCapabilities format
New PrintSchema document type used to generate PrintCapabilities and PrintTicket. Includes simple constraints and options for PWG Raster consumers. ... <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:DuplexPageOrder>Standard</psf2:DuplexPageOrder> <psf2:PwgRasterDocumentTypesSupported> <psf2:PwgRasterDocumentType psf2:PageOutputColor="psk:Color"> Srgb_8 </psf2:PwgRasterDocumentType>

32 ResX format <?xml version="1.0" encoding="utf-8"?> <root
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. <?xml version="1.0" encoding="utf-8"?> <root xmlns:xml=" xmlns:xsd=" xmlns:xsi=" <data name="schemas.contoso.com/2014/printschema/Main"> <value>Main paper tray</value> </data> </root>

33 Printer IHV Call to Action
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 for information about including support for these

34 For More Information 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

35


Download ppt "2-94 Developing apps and devices that print in Windows 10 and Windows 10 Mobile Justin Hutchings Senior Program Manager Operating Systems Group."

Similar presentations


Ads by Google