GithubHelp home page GithubHelp logo

isabella232 / cordova-plugin-printer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moderna/cordova-plugin-printer

0.0 0.0 0.0 1.11 MB

A bunch of printing plugins for Cordova 3.x.x

License: Apache License 2.0

Java 69.67% Objective-C 24.45% JavaScript 5.88%

cordova-plugin-printer's Introduction

Cordova Printer-Plugin

A printig plugin for Cordova 6.1.1+ (android >= 4.1 and ios >= 6)

original credit goes to Sebastián Katzer (github.com/katzer)

Supported Platforms

Adding the Plugin to your project

Through the Command-line Interface:

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

Removing the Plugin from your project

Through the Command-line Interface:

cordova plugin rm de.appplant.cordova.plugin.printer

Release Notes

Version 1.0.0 (28.4.2016)

  • compatibility release for cordova 6.1.1+ (tested on 6.1.1)

Version 0.6.0 (27.4.2016)

  • Release created for old versins (cordova 3.3.x)
  • We ahve never tested it on 4.x or 5.x

Version 0.5.0 (11.12.2013)

  • Release under the Apache 2.0 license.
  • [change:] Removed the callback property from the print interface.
  • [enhancement:] Added Android KitKat support
    Based on the Print Android plugin made by Eion Robb

Version 0.4.0 (24.08.2013)

  • [feature]: Added Android support
    Based on the Print Android plugin made by Eion Robb
  • [feature]: print() accepts a 4th arguments for platform specific properties.
  • [change]: the callback of print() will be called with a result code about the user action.

Version 0.2.1 (13.08.2013)

  • [feature]: Support for callback scopes.

Version 0.2.0 (11.08.2013)

  • [feature]: Added iOS support
    Based on the Print iOS plugin made by Randy McMillan

Using the plugin

The plugin creates the object window.plugin.printer with two methods:

isServiceAvailable()

Printing is only available on devices capable of multi-tasking (iPhone 3GS, iPhone 4 etc.) running iOS 4.2 or later. You can use this function to hide print functionality from users who will be unable to use it.
Function takes a callback function, passed to which is a boolean property. Optionally you can assign the scope in which the callback will be executed as a second parameter (default to window).

/*
 * Find out if printing is available. Use this for showing/hiding print buttons.
 */
window.plugin.printer.isServiceAvailable(
    function (isAvailable) {
        alert(isAvailable ? 'Service is available' : 'Service NOT available');
    }
);

print()

Function takes an html string.

Note: All required CSS rules needs to be included as well.

// Get HTML string
var page = document.body.innerHTML;

// Pass the HTML
window.plugin.printer.print(page);

Quirks

Testing in the iOS Simulator

There's no need to waste lots of paper when testing - if you're using the iOS simulator, select File->Open Printer Simulator to open some dummy printers (print outs will appear as PDF files).

Adding Page Breaks to Printouts

Use the 'page-break-before' property to specify a page break, e.g.

<p>
First page.
</p>

<p style="page-break-before: always">
Second page.
</p>

See W3Schools for more more information: http://www.w3schools.com/cssref/pr_print_pagebb.asp

Note: you will need to add an extra top margin to new pages.

Printing on Real Printers (iOS)

Printing is only supported on AirPrint-enabled printers or with the use of third-party software on your computer. The following pages contain more information:

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.

cordova-plugin-printer's People

Contributors

katzer avatar geo-ma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.