All Projects → EddyVerbruggen → nativescript-printer

EddyVerbruggen / nativescript-printer

Licence: MIT License
📠 Send an image or the screen contents to a physical printer

Programming Languages

typescript
32286 projects
shell
77523 projects

Projects that are alternatives of or similar to nativescript-printer

nativescript-star-printer
🌟 Print directly to Star Micronics printers from your NativeScript app! http://www.starmicronics.com/
Stars: ✭ 28 (-15.15%)
Mutual labels:  printer, nativescript, nativescript-plugin
nativescript-pushy
Easy push notifications for your NativeScript app!
Stars: ✭ 19 (-42.42%)
Mutual labels:  nativescript, nativescript-plugin
ui
Add right-to-left support to the NativeScript framework
Stars: ✭ 22 (-33.33%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-clipboard
📋 NativeScript plugin to copy stuff to the device clipboard, and read from it again
Stars: ✭ 40 (+21.21%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-performance-monitor
⚡ Proof your app maintains 60-ish FPS by collecting data or showing it on screen with this NativeScript plugin!
Stars: ✭ 21 (-36.36%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-apple-sign-in
Sign In With Apple, as seen on WWDC 2019, available with iOS 13
Stars: ✭ 37 (+12.12%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-vue-examples
🍈 NativeScript and Vue code samples.
Stars: ✭ 13 (-60.61%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-ng-shadow
Angular directive to apply shadows to native elements according to the elevation level guidelines of material design specification
Stars: ✭ 54 (+63.64%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-drawingpad
📝 NativeScript plugin to provide a way to capture any drawing (signatures are a common use case) from the device
Stars: ✭ 89 (+169.7%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-http
The best way to do HTTP requests in NativeScript, a drop-in replacement for the core HTTP with important improvements and additions like proper connection pooling, form data support and certificate pinning
Stars: ✭ 32 (-3.03%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-appversion
🔢 NativeScript plugin to retrieve your app's package ID and current version
Stars: ✭ 47 (+42.42%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-menu
A plugin that adds a pop-up menu to NativeScript
Stars: ✭ 17 (-48.48%)
Mutual labels:  nativescript, nativescript-plugin
texttospeech
Text to Speech NativeScript plugin for Android & iOS 📢
Stars: ✭ 44 (+33.33%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-app-icon-changer
Change the homescreen icon of your NativeScript iOS app at runtime!
Stars: ✭ 16 (-51.52%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-image-filters
NativeScript plugin to apply filters to images
Stars: ✭ 30 (-9.09%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-taptic-engine
📳 Use Apple's Taptic Engine to vibrate your iPhone 6s (and up) in a variety of ways
Stars: ✭ 16 (-51.52%)
Mutual labels:  nativescript, nativescript-plugin
Codeprinter
🖨️ Print out code easily
Stars: ✭ 233 (+606.06%)
Mutual labels:  printer, print
nativescript-store-update
No description or website provided.
Stars: ✭ 18 (-45.45%)
Mutual labels:  nativescript, nativescript-plugin
nativescript-app-shortcuts
👇 Home Icon Actions for your NativeScript app, now also for Android!
Stars: ✭ 45 (+36.36%)
Mutual labels:  nativescript, nativescript-plugin
insomnia
😪 NativeScript plugin to keep the device awake (not dim the screen, lock, etc)
Stars: ✭ 40 (+21.21%)
Mutual labels:  nativescript, nativescript-plugin

NativeScript Printer plugin

Build Status NPM version Downloads Twitter Follow

Think about the environment before printing!

Installation

From the command prompt go to your app's root folder and execute:

tns plugin add nativescript-printer

Demo app

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.

Android screenshots

    

iOS screenshots

    

API

isSupported

Not all devices support printing, so it makes sense to check the device capabilties beforehand.

TypeScript
// require the plugin
import {Printer} from "nativescript-printer";

// instantiate the plugin
let printer = new Printer();

printer.isSupported().then((supported) => {
  alert(supported ? "Yep!" : "Nope :'(");
}, (error) => {
  alert("Error: " + error);
});

printImage

TypeScript
// let's load an image that we can print. In this case from a local folder.
let fs = require("file-system");
let appPath = fs.knownFolders.currentApp().path;
let imgPath = appPath + "/res/printer.png";
let imgSrc = new ImageSource();
imgSrc.loadFromFile(imgPath);

printer.printImage({
  imageSrc: imgSrc
}).then((success) => {
  alert(success ? "Printed!" : "Not printed");
}, (error) => {
  alert("Error: " + error);
});

printPDF

TypeScript
import { knownFolders } from "tns-core-modules/file-system/file-system";

printer.printPDF({
  pdfPath: knownFolders.currentApp().path + "/pdf-test.pdf"
}).then((success) => {
  alert(success ? "Printed!" : "Not printed");
}, (error) => {
  alert("Error: " + error);
});

printScreen

Prints the current screen contents. Anything off screen will not be printed.

TypeScript
printer.printScreen().then((success) => {
  alert(success ? "Printed!" : "Not printed");
}, (error) => {
  alert("Error: " + error);
});

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

  <StackLayout id="printMe">
    <Label text="Print me :)" />
  </StackLayout>

  <Button text="Print" tap="{{ print }}" />
  public print(args) {
    printer.printScreen({
      view: args.object.page.getViewById("printMe")
    });
  }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].