Windows Style App Print Manager HTML 5 XAML



































- Slides: 35




Windows Style App Print Manager HTML 5 XAML Direct 2 D XPS Print Document Package Target API Print API App rendering API Windows Runtime Windows Print Spooler (Desktop) Windows Print Job Manager (Mobile) Printer Drivers

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 Win 32 etc. Windows 10 Mobile Network Installed on demand • Supported printers work automatically • Unsupported printers not shown Only Windows 10 Mobile Windows Apps compatible printers • Must support WS-Print protocol • Must support a standard PDL






Windows Style App Print Manager HTML 5 XAML Direct 2 D XPS Print Document Package Target API Print API App rendering API Windows Runtime Windows Print Spooler (Desktop) Windows Print Job Manager (Mobile) Printer Drivers


void register. For. Printing() { //Register for Print. Task. Requested event Print. Manager = Print. Manager. Get. For. Current. View(); Print. Manager. Print. Task. Requested += Print. Manager_Print. Task. Requested; //Build a Print. Document and register for callbacks this. Document = new Print. Document(); this. Document. Paginate += Paginate; this. Document. Get. Preview. Page += Get. Preview. Page; this. Document. Add. Pages += Add. Pages; }

void Print. Manager_Print. Task. Requested(Print. Manager sender, Print. Task. Requested. Event. Args args) { // Create the Print. Task. // Defines the title and delegate for Print. Task. Source. Requested Print. Task print. Task = args. Request. Create. Print. Task("Print Job Title", Print. Task. Source. Requested); // Handle Print. Task. Completed to catch failed print jobs print. Task. Completed += Print. Task. Completed; // Configure app specific features for print dialog configure. Print. Task. Option. Details(print. Task); }

void configure. Print. Task. Option. Details(Print. Task print. Task) { Print. Task. Option. Details details = Print. Task. Option. Details. Get. From. Print. Task. Options(print. Task. Options); IList<string> displayed. Options = details. Displayed. Options; // Create a new list option Print. Custom. Item. List. Option. Details fit = details. Create. Item. List. Option("Fit", "Fit to Page"); fit. Add. Item("Scale", "Scale to Fit"); fit. Add. Item("Crop", "Crop to Fit"); // Add the custom option to the option list, handle changes displayed. Options. Add("Fit"); details. Option. Changed += details_Option. Changed; }

void Print. Task. Source. Requested(Print. Task. Source. Requested. Args args) { // Set the document source. This should be initialized in // advance due to short timeouts for this event. args. Set. Source(this. Document. Source); }


void Paginate(object sender, Paginate. Event. Args e) { // Fired every time that the Print. Task. Options change // Paginate. Event. Args has a copy of current Print. Task. Options // Do any necessary work to determine how many // pages are in the printable content // then set the page count. this. Document. Set. Preview. Page. Count(this. Pages. Count, Preview. Page. Count. Type. Final); }

void Get. Preview. Page(object sender, Get. Preview. Page. Event. Args e) { // Provide a UIElement as the print preview. // Keep in mind the 1 -based indexing for print page numbers int zero. Based. Page. Number = e. Page. Number - 1; this. Document. Set. Preview. Page(e. Page. Number, this. Pages[zero. Based. Page. Number]. Image as UIElement); }


void Print. Task. Option. Details Print. Task. Option. Changed. Event. Args // Find out what option changed if null IPrint. Option. Details switch // Handle selected option cases here "Fit"

async void Add. Pages(object sender, Add. Pages. Event. Args e) { //Loop through pages to print and add to Print. Document for (int page. Num = 0; page. Num < this. Pages. Count; page. Num++) { var page. Desc = e. Print. Task. Options. Get. Page. Description((uint)page. Num); var current. Page = this. Pages[page. Num]; // Render UIElement in target resolution; DIP = 1/96” this. Document. Add. Page(await current. Page. Get. Page. In. Target. Resolution( (page. Desc. Imageable. Rect. Width*Dpi. X)/96), (page. Desc. Imageable. Rect. Height*Dpi. Y)/96)); } this. Document. Add. Pages. Complete(); }

void if Print. Task. Completed. Event. Args Print. Task. Completion // Notify the user in UI Message. Dialog("Printing failed. "

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


Standard Windows 10 Mobile Open. XPS (ECMA-388) ✓ ✓ PWG Raster (PWG-5102. 4 -2012) ✓ ✓ PCLm (WFA WFDS-Print) ✓

prninfo@microsoft. com




. . . <psk: Job. Duplex. All. Documents. Contiguously psf 2: psftype="Feature"> <psk: One. Sided psf 2: psftype="Option" psf 2: default="true"/> <psk: Two. Sided. Long. Edge psf 2: psftype="Option"/> <psk: Two. Sided. Short. Edge psf 2: psftype="Option"/> </psk: Job. Duplex. All. Documents. Contiguously> <psf 2: Invalid. Combination. Entry psf 2: feature="psk: Page. Media. Type" psf 2: option="psk: Transparency"/> <psf 2: Invalid. Combination. Entry psf 2: feature="psk: Job. Duplex. All. Documents. Contiguously" psf 2: option="psk: Two. Sided. Long. Edge"/> </psf 2: Invalid. Combination> <psf 2: Document. Format. Options> <psf 2: Pwg. Raster. Backside. Tumble psf 2: Duplex. Type="psk: Two. Sided. Short. Edge"> true </psf 2: Pwg. Raster. Backside. Tumble> <psf 2: Pwg. Raster. Backside. Tumble psf 2: Duplex. Type="psk: Two. Sided. Long. Edge"> false </psf 2: Pwg. Raster. Backside. Tumble> <psf 2: Duplex. Page. Order>Standard</psf 2: Duplex. Page. Order> <psf 2: Pwg. Raster. Document. Types. Supported> <psf 2: Pwg. Raster. Document. Type psf 2: Page. Output. Color="psk: Color"> Srgb_8 </psf 2: Pwg. Raster. Document. Type>. . .

<? xml version="1. 0" encoding="utf-8"? > <root xmlns: xml="http: //www. w 3. org/XML/1998/namespace" xmlns: xsd="http: //www. w 3. org/2001/XMLSchema" xmlns: xsi="http: //www. w 3. org/2001/XMLSchemainstance"> <data name="schemas. contoso. com/2014/printschema/Main"> <value>Main paper tray</value> </data> </root>

prninfo@microsoft. com

Developing printers that support Windows 10 Mobile Print Schema Specification v 2. 0 WSD Print Service Specification v 2. 0 v 4 Print Driver Improvements in Windows 10 Device Profile For Web Services Location Extension
