{"id":15282594,"url":"https://github.com/eddyverbruggen/nativescript-printer","last_synced_at":"2025-04-15T16:51:28.622Z","repository":{"id":14099083,"uuid":"75974028","full_name":"EddyVerbruggen/nativescript-printer","owner":"EddyVerbruggen","description":":fax: Send an image or the screen contents to a physical printer","archived":false,"fork":false,"pushed_at":"2024-02-28T07:35:17.000Z","size":2847,"stargazers_count":37,"open_issues_count":21,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T22:41:25.250Z","etag":null,"topics":["nativescript","nativescript-plugin","print","printer","screenshot"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EddyVerbruggen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-08T20:48:47.000Z","updated_at":"2024-10-30T10:18:23.000Z","dependencies_parsed_at":"2024-10-14T14:31:18.690Z","dependency_job_id":null,"html_url":"https://github.com/EddyVerbruggen/nativescript-printer","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-printer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-printer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-printer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-printer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EddyVerbruggen","download_url":"https://codeload.github.com/EddyVerbruggen/nativescript-printer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249113519,"owners_count":21214911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nativescript","nativescript-plugin","print","printer","screenshot"],"created_at":"2024-09-30T14:31:27.810Z","updated_at":"2025-04-15T16:51:28.592Z","avatar_url":"https://github.com/EddyVerbruggen.png","language":"TypeScript","readme":"# NativeScript Printer plugin\n\n[![Build Status][build-status]][build-url]\n[![NPM version][npm-image]][npm-url]\n[![Downloads][downloads-image]][npm-url]\n[![Twitter Follow][twitter-image]][twitter-url]\n\n[build-status]:https://travis-ci.org/EddyVerbruggen/nativescript-printer.svg?branch=master\n[build-url]:https://travis-ci.org/EddyVerbruggen/nativescript-printer\n[npm-image]:http://img.shields.io/npm/v/nativescript-printer.svg\n[npm-url]:https://npmjs.org/package/nativescript-printer\n[downloads-image]:http://img.shields.io/npm/dm/nativescript-printer.svg\n[twitter-image]:https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social\u0026label=Follow%20me\n[twitter-url]:https://twitter.com/eddyverbruggen\n\n\u003e Think about the environment before printing!\n\n## Installation\nFrom the command prompt go to your app's root folder and execute:\n\n```\ntns plugin add nativescript-printer\n```\n\n## Demo app\nWant to dive in quickly? Check out [the demo](https://github.com/EddyVerbruggen/nativescript-printer/tree/master/demo)! Otherwise, continue reading.\n\nRun the demo app from the root of the project: `npm run demo.ios` or `npm run demo.android`.\n\n### Android screenshots\n\u003cimg src=\"https://raw.githubusercontent.com/EddyVerbruggen/nativescript-printer/master/screenshots/android/android-select-printer.png\" width=\"375px\"/\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cimg src=\"https://raw.githubusercontent.com/EddyVerbruggen/nativescript-printer/master/screenshots/android/android-printer-options.png\" width=\"375px\"/\u003e\n\n### iOS screenshots\n\u003cimg src=\"https://raw.githubusercontent.com/EddyVerbruggen/nativescript-printer/master/screenshots/ios/ios-select-printer.png\" width=\"375px\"/\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cimg src=\"https://raw.githubusercontent.com/EddyVerbruggen/nativescript-printer/master/screenshots/ios/ios-printing-in-progress.png\" width=\"375px\"/\u003e\n\n## API\n\n### `isSupported`\nNot all devices support printing, so it makes sense to check the device capabilties beforehand.\n\n##### TypeScript\n```typescript\n// require the plugin\nimport {Printer} from \"nativescript-printer\";\n\n// instantiate the plugin\nlet printer = new Printer();\n\nprinter.isSupported().then((supported) =\u003e {\n  alert(supported ? \"Yep!\" : \"Nope :'(\");\n}, (error) =\u003e {\n  alert(\"Error: \" + error);\n});\n```\n\n### `printImage`\n\n##### TypeScript\n```typescript\n// let's load an image that we can print. In this case from a local folder.\nlet fs = require(\"file-system\");\nlet appPath = fs.knownFolders.currentApp().path;\nlet imgPath = appPath + \"/res/printer.png\";\nlet imgSrc = new ImageSource();\nimgSrc.loadFromFile(imgPath);\n\nprinter.printImage({\n  imageSrc: imgSrc\n}).then((success) =\u003e {\n  alert(success ? \"Printed!\" : \"Not printed\");\n}, (error) =\u003e {\n  alert(\"Error: \" + error);\n});\n```\n\n### `printPDF`\n\n##### TypeScript\n```typescript\nimport { knownFolders } from \"tns-core-modules/file-system/file-system\";\n\nprinter.printPDF({\n  pdfPath: knownFolders.currentApp().path + \"/pdf-test.pdf\"\n}).then((success) =\u003e {\n  alert(success ? \"Printed!\" : \"Not printed\");\n}, (error) =\u003e {\n  alert(\"Error: \" + error);\n});\n```\n\n### `printScreen`\nPrints the current screen contents. Anything off screen will not be printed.\n\n##### TypeScript\n```typescript\nprinter.printScreen().then((success) =\u003e {\n  alert(success ? \"Printed!\" : \"Not printed\");\n}, (error) =\u003e {\n  alert(\"Error: \" + error);\n});\n```\n\nYou can also print a specific portion of the screen, which also enables you to print\nviews that are larger than the viewport. This is an example of a non-Angular NativeScript app:\n\n**Note**\nIf the view is either of the following depending on the size of it's contents it would break into multiple pages.\n\n`Label | TextView | HtmlView | WebView`\n\n```xml\n  \u003cStackLayout id=\"printMe\"\u003e\n    \u003cLabel text=\"Print me :)\" /\u003e\n  \u003c/StackLayout\u003e\n\n  \u003cButton text=\"Print\" tap=\"{{ print }}\" /\u003e\n```\n\n```js\n  public print(args) {\n    printer.printScreen({\n      view: args.object.page.getViewById(\"printMe\")\n    });\n  }\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddyverbruggen%2Fnativescript-printer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddyverbruggen%2Fnativescript-printer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddyverbruggen%2Fnativescript-printer/lists"}