NativeScript Printer plugin
Think about the environment before printing!
From the command prompt go to your app's root folder and execute:
tns plugin add nativescript-printer
Want to dive in quickly? Check out the demo! Otherwise, continue reading.
Run the demo app from the root of the project:
npm run demo.ios or
npm run demo.android.
Not all devices support printing, so it makes sense to check the device capabilties beforehand.
// require the plugin;// instantiate the plugin;printer.isSupported.then,;
// let's load an image that we can print. In this case from a local folder.;;;;imgSrc.loadFromFileimgPath;printer.printImage.then,;
Prints the current screen contents. Anything off screen will not be printed.
You can also print a specific portion of the screen, which also enables you to print views that are larger than the viewport. This is an example of a non-Angular NativeScript app:
Note If the view is either of the following depending on the size of it's contents it would break into multiple pages.
Label | TextView | HtmlView | WebView