graphic - Dave's Blog

Search
My timeline on Mastodon

MSApp.getHtmlPrintDocumentSourceAsync - JavaScript UWP app printing

2017 Oct 11, 5:49

The documentation for printing in JavaScript UWP apps is out of date as it all references MSApp.getHtmlPrintDocumentSource but that method has been replaced by MSApp.getHtmlPrintDocumentSourceAsync since WinPhone 8.1.

Background

Previous to WinPhone 8.1 the WebView's HTML content ran on the UI thread of the app. This is troublesome for rendering arbitrary web content since in the extreme case the JavaScript of some arbitrary web page might just sit in a loop and never return control to your app's UI. With WinPhone 8.1 we added off thread WebView in which the WebView runs HTML content on a separate UI thread.

Off thread WebView required changing our MSApp.getHtmlPrintDocumentSource API which could no longer synchronously produce an HtmlPrintDocumentSource. With WebViews running on their own threads it may take some time for them to generate their print content for the HtmlPrintDocumentSource and we don't want to hang the app's UI thread in the interim. So the MSApp.getHtmlPrintDocumentSource API was replaced with MSApp.getHtmlPrintDocumentSourceAsync which returns a promise the resolved value of which is the eventual HtmlPrintDocumentSource.

Sample

However, the usage of the API is otherwise unchanged. So in sample code you see referencing MSApp.getHtmlPrintDocumentSource the sample code is still reasonable but you need to call MSApp.getHtmlPrintDocumentSourceAsync instead and wait for the promise to complete. For example the PrintManager docs has an example implementing a PrintTaskRequested event handler in a JavaScript UWP app.

    function onPrintTaskRequested(printEvent) {    
var printTask = printEvent.request.createPrintTask("Print Sample", function (args) {
args.setSource(MSApp.getHtmlPrintDocumentSource(document));
});

Instead we need to obtain a deferral in the event handler so we can asynchronously wait for getHtmlPrintDocumentSourceAsync to complete:

    function onPrintTaskRequested(printEvent) {    
var printTask = printEvent.request.createPrintTask("Print Sample", function (args) {
const deferral = args.getDeferral();
MSApp.getHtmlPrintDocumentSourceAsync(document).then(htmlPrintDocumentSource => {
args.setSource(htmlPrintDocumentSource);
deferral.complete();
}, error => {
console.error("Error: " + error.message + " " + error.stack);
deferral.complete();
});
});
PermalinkCommentsjavascript MSApp printing programming uwp webview win10 windows

Tweet from David_Risney

2015 Jul 20, 3:21
Difficulties of props in entertainment: matching viewer expectations not reality, HD, trademarks, and currency. http://www.bloomberg.com/graphics/2015-property-master/ …
PermalinkComments

Retweet of covernode

2015 Apr 6, 6:26
Shut it down infographics nerds, the greatest chart possible has been made pic.twitter.com/LZr6KRwhJP
PermalinkComments

WIRED: Our exclusive hands-on with Microsoft’s unbelievable new holographic goggles

2015 Jan 20, 9:15
WIRED        ✔ @WIRED :
Our exclusive hands-on with Microsoft’s unbelievable new holographic goggles http://wrd.cm/1CBSqwN  pic.twitter.com/VufKcTcSfE
PermalinkComments

Where the best designers go to find photos and graphics

2014 Jan 5, 3:09

List of useful free or CC licensed photography and icon sites.

PermalinkCommentsfree cc photo photography icon

A Slower Speed of Light Official Trailer — MIT Game Lab (by...

2012 Nov 13, 7:41


A Slower Speed of Light Official Trailer — MIT Game Lab (by Steven Schirra)

“A Slower Speed of Light is a first-person game in which players navigate a 3D space while picking up orbs that reduce the speed of light in increments. A custom-built, open-source relativistic graphics engine allows the speed of light in the game to approach the player’s own maximum walking speed. Visual effects of special relativity gradually become apparent to the player, increasing the challenge of gameplay. These effects, rendered in realtime to vertex accuracy, include the Doppler effect; the searchlight effect; time dilation; Lorentz transformation; and the runtime effect.

A production of the MIT Game Lab.

Play now for Mac and PC! http://gamelab.mit.edu/games/a-slower-speed-of-light/

PermalinkCommentsscience game video-game mit 3d light-speed

IKEA's New Catalogs: Less Pine, More Pixels - WSJ.com

2012 Aug 24, 3:15

CGI for the IKEA catalog:

That couch catching your eye in the 2013 edition of IKEA’s new catalog may not be a couch at all. It is likely the entire living room was created by a graphic artist. In fact, much of the furniture and settings in the 324-page catalog are simply a collection of pixels and polygons arranged on a computer.

PermalinkComments3d photo graphics ikea

Newsroom: Miscellaneous: New Online Tool Gives Public Wider Access to Key U.S. Statistics

2012 Jul 28, 2:35

The U.S. Census Bureau today released a new online service that makes key demographic, socio-economic and housing statistics more accessible than ever before. The Census Bureau’s first-ever public Application Programming Interface (API) allows developers to design Web and mobile apps to explore or learn more about America’s changing population and economy.

PermalinkCommentstechnical api census statistics stats web restful rest

Windows Executable Walkthrough Graphic (corkami.com)

2012 Jul 19, 5:58

Breakdown of the bytes of a Windows executable in a big old chart!

PermalinkCommentstechnical windows programming

My Hometown Is Better Than Yours « Rottin' in Denmark

2012 Jan 6, 6:20

FTA: “Three mountain ranges, four lakes and a fucking Sound. That’s a geographical feature your hometown hasn’t even heard of.”

PermalinkCommentshumor via-ericlaw seattle

(via Streetview Stereographic is Warping Google Maps)

2012 Jan 6, 6:15


(via Streetview Stereographic is Warping Google Maps)

PermalinkCommentsmap photo

Telex

2011 Jul 18, 2:38Neat idea: "When the user wants to visit a blacklisted site, the client establishes an encrypted HTTPS connection to a non-blacklisted web server outside the censor’s network, which could be a normal site that the user regularly visits... The client secretly marks the connection as a Telex request by inserting a cryptographic tag into the headers. We construct this tag using a mechanism called public-key steganography... As the connection travels over the Internet en route to the non-blacklisted site, it passes through routers at various ISPs in the core of the network. We envision that some of these ISPs would deploy equipment we call Telex stations."PermalinkCommentsinternet security tools censorship technical

Lifetimes of cryptographic hash functions

2011 Jun 20, 11:25A cautionary tale in chart form: lesson is make sure you can always upgrade your hashing algorithm or don't have security dependencies on hashing algorithms.PermalinkCommentsreference hash encryption security table technical humor

Notabilia – Visualizing Deletion Discussions on Wikipedia

2011 Jan 10, 9:41PermalinkCommentswikipedia visualization infographics design analysis humor

JavaScript InfoVis Toolkit

2010 Jul 8, 1:37Including graphs with force directed layout!PermalinkCommentsvia:mattb infographics javascript technical programming html graph chart visualization

tenso GRAPHICS

2010 Jun 19, 3:54
PermalinkCommentskeytar humor math diagram keyboard duck

RFC 5870 - A Uniform Resource Identifier for Geographic Locations ('geo' URI)

2010 Jun 9, 3:31"A 'geo' URI identifies a physical location in a two- or three-dimensional coordinate reference system in a compact, simple, human-readable, and protocol-independent way."PermalinkCommentstechnical geo uri url ietf rfc standard

RFC 5854 - The Metalink Download Description Format

2010 Jun 1, 6:46"Metalink describes download locations (mirrors), cryptographic hashes, and other information. Clients can transparently use this information to reliably transfer files."PermalinkCommentstechnical internet download web url xml metalink

Schneier on Security: Alerting Users that Applications are Using Cameras, Microphones, Etc.

2010 May 24, 6:26"What You See is What They Get: Protecting users from unwanted use of microphones, cameras, and other sensors," by Jon Howell and Stuart Schechter.

"We introduce the sensor-access widget, a graphical user interface element that resides within an application's display. The widget provides an animated representation of the personal data being collected by its corresponding sensor, calling attention to the application's attempt to collect the data."

Not sure how well that scales...PermalinkCommentstechnical security privacy research

notes.husk.org. “Infographic” (by Phil Gyford, repurposed under a....

2010 Apr 11, 3:55Humour infographic backlash infographic.
PermalinkCommentsinformation infographics humor technical
Older Entries Creative Commons License Some rights reserved.