npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-printer-dev

v0.0.1

Published

Prints HTML documents

Downloads

9

Readme

Cordova Print Plugin npm version Build Status

Plugin for the Cordova framework to print HTML from iOS, Android and Windows Universal apps.

About Apple AirPrint

AirPrint is an Apple™ technology that helps you create full-quality printed output without the need to download or install drivers. AirPrint is built in to many printer models from most popular printer manufacturers. Just select an AirPrint printer on your local network to print from your favorite iOS or OS X app.

See Drawing and Printing Guide for iOS for detailed informations.

About Android Printing Framework

Starting with KitKat, most Android devices have print service plugins installed to enable printing using the Google Cloud Print and Google Drive services. Print service plugins from other printer manufactures are available through the App Store though the Google Cloud Print service plugin can also be used to print from an Android device to just about any printer type and model. In addition to supporting physical printers, it is also possible to save printed output to your Google Drive account or locally as a PDF file on the Android device.

See Building Apps with Multimedia for Android for detailed informations.

Supported Platforms

  • iOS 8 or newer
  • Android KitKat or newer
  • Universal Windows Platform

Installation

Install the latest version:

cordova plugin add cordova-plugin-printer

Or a specific version:

cordova plugin add cordova-plugin-printer@VERSION

Or the latest dev version:

cordova plugin add https://github.com/katzer/cordova-plugin-printer.git

Or a custom version:

cordova plugin add cordova-plugin-printer --searchpath path/to/plugin

And then execute:

cordova build

ChangeLog

Version 0.7.4 (not yet released)

  • Fix broken check and pick on Android N and above

Version 0.7.3 (19.12.2016)

  • Fixed incompatibility with Android KitKat (4.4)

Known limitations

  • Plugin crashes on Windows OS 10.0.14
  • check on Android might return empty result as some versions of cordova seems to have a bug with multipart results.

See CHANGELOG.md to get the full changelog for the plugin.

Usage

The plugin and its methods are not available before the deviceready event has been fired.

document.addEventListener('deviceready', function () {
    // cordova.plugins.printer is now available
}, false);

Check printer

The device his printing capabilities can be reviewed through the printer.check interface. Use this function to hide print functionality from users who will be unable to use it.

/**
 * Checks if the printer service is avaible (iOS)
 * or if printer services are installed and enabled (Android).
 *
 * @param {Function} callback
 *      A callback function
 * @param {Object} scope
 *      Optional scope of the callback
 *      Defaults to: window
 */
cordova.plugins.printer.check(function (avail, count) {
    alert(avail ? 'Found ' + count + ' services' : 'No');
});

Pick a printer

Displays a system interface allowing the user to select an available printer. To speak with a printer directly you need to know the network address by picking them before via printer.pick.

Note that picking a printer is not supported for windows platform.

/**
 * Displays system interface for selecting a printer.
 *
 * @param {Function} callback
 *      A callback function
 */
cordova.plugins.printer.pick(function (uri) {
    alert(uri ? uri : 'Canceled');
});

Print content

Content can be send to a printer through the printer.print interface. The method takes a string with HTML content, an URI pointing to another web page or any DOM node.

/**
 * Sends the content to print service.
 *
 * @param {String} content
 *      HTML string or DOM node
 *      if latter, innerHTML is used to get the content
 * @param {Object} options
 *       Options for the print job
 * @param {Function} callback
 *      An optional callback function
 * @param {Object} scope
 *      An optional scope of the callback
 *      Defaults to: window
 */
cordova.plugins.printer.print('<html>..</html>', { duplex: 'long' }, function (res) {
    alert(res ? 'Done' : 'Canceled');
});

The method accepts a list of attributes. Not all are supported on each platform and by each printer!

| Name | Description | Type | Platform | |:---- |:----------- |:----:| --------:| | name | The name of the print job and of the document | String | all | | duplex | Specifies the duplex mode to use for the print job.Either double-sided on short site (duplex:'short'), double-sided on long site (duplex:'long') or single-sided (duplex:'none').Defaults to: 'none' | String | all | | landscape| The orientation of the printed content, portrait or landscape.Defaults to: false | Boolean | all | | graystyle | If your application only prints black text, setting this property to true can result in better performance in many cases.Defaults to: false | Boolean | all | | printerId | The network URL to the printer. | String | iOS | | border | Set to false to skip any border. Useful for fullscreen images.Defaults to: true | Boolean | iOS | | hidePageRange | Set to true to hide the control for the page range.Defaults to: false | Boolean | iOS | | hideNumberOfCopies | Set to true to hide the control for the number of copies.Defaults to: false | Boolean | iOS | | hidePaperFormat | Set to true to hide the control for the paper format.Defaults to: false | Boolean | iOS | | bounds | The Size and position of the print viewDefaults to: [40, 30, 0, 0] | Array | iPad |

Further informations

  • All CSS rules needs to be embedded or accessible via absolute URLs in order to print out HTML encoded content.
  • The string can contain HTML content or an URI pointing to another web page.

Examples

NOTE: All CSS rules needs to be embedded or accessible via absolute URLs in order to print out HTML encoded content.

Print the whole HTML page:

var page = location.href;

cordova.plugins.printer.print(page, 'Document.html');

Print the content from one part of the page:

var page = document.getElementById('legal-notice');

cordova.plugins.printer.print(page, 'Document.html');

Print some custom content:

var page = '<h1>Hello Document</h1>';

cordova.plugins.printer.print(page, 'Document.html');

Print a remote web page:

cordova.plugins.printer.print('http://blackberry.de', 'BB10');

Send to printer directly:

cordova.plugins.printer.pick(function (uri) {
    cordova.plugins.printer.print(page, { printerId: uri });
});

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

This software is released under the Apache 2.0 License.

Made with :yum: from Leipzig

© 2016 appPlant GmbH