Search code examples
cordovawindows-8.1winjs

WinJS programmatically take screenshot of app


I'm working on a Cordova application for Windows 8.1 and I'm trying to build a plugin that can take a screenshot of the app. I've looked around MSDN, but haven't found anything that can do that. This kind of plugin exists for iOS and Android ( https://github.com/gitawego/cordova-screenshot ), but I haven't been able to find a Windows equivalent for this yet.


Solution

  • There isn't a good way to do this.

    Windows Store apps don't have any explicit screenshot API (Windows Phone Store apps do have a phone-only ScreenCapture API) and HTML and JavaScript don't provide a way to render arbitrary HTML to a bitmap (such as Xaml's RenderTargetBitmap). You render the contents of a Canvas or a WebView, but not the page itself.

    Depending on what you have in your HTML you may be able to use a library such as http://html2canvas.hertzen.com/ to traverse the DOM and render it into a Canvas which you can convert to a bitmap with toDataUrl.