GithubHelp home page GithubHelp logo

san0suke / cordova-plugin-bixolon-printing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itskaynine/cordova-plugin-bixolon-printing

0.0 2.0 0.0 2.87 MB

Bixolon mobile printer plugin for Cordova

License: Apache License 2.0

Java 66.69% JavaScript 33.31%

cordova-plugin-bixolon-printing's Introduction

Cordova Bixolon Printer Plugin

Cordova plugin for Bixolon mobile printers using the official UPOS compliant API.

NOTE

For simplicity, only image (bitmap) printing are allowed.

Supported Platforms

  • Android
  • iOS (TODO)

Install

Cordova CLI

$ cordova plugin add https://github.com/itsKaynine/cordova-plugin-bixolon-printing.git

Phonegap CLI

$ phonegap local plugin add https://github.com/itsKaynine/cordova-plugin-bixolon-printing.git

Global Options

cordova.plugins.BixolonPrinting.printConfig = {
  lineFeed: 3,
  formFeed: false
};

Usage

Connect to printer

cordova.plugins.BixolonPrinting.connect(successCallback, errorCallback, {
    logicalDeviceName: String,
    deviceBus: int, // cordova.plugins.BixolonPrinting.DEVICE_BUS
    address: String,
    secure: Boolean
});

Print bitmap image

cordova.plugins.BixolonPrinting.printBitmap(successCallback, errorCallback, {
    base64Image: String,
    width: int,
    brightness int, // 0 to 100 (Bixolon recommeded 13 to 88)
    alignment: int // cordova.plugins.BixolonPrinting.ALIGNMENT
});

Disconnect from printer

cordova.plugins.BixolonPrinting.disconnect(successCallback, errorCallback);

Example

Printing through Wi-Fi

// Put your base64 encoded image string here
var b64Image = "<Base64 Encoded Image>";

function alertError(err) {
    alert("ERROR: " + err);
};

// Define connection to printer
var connection = {
    logicalDeviceName: "SPP-R310",
    deviceBus: cordova.plugins.BixolonPrinting.DEVICE_BUS.WIFI,
    address: "10.0.1.21",
    secure: false
};

// Connect to printer
cordova.plugins.BixolonPrinting.connect(
    function(res) {

        // Printing options
        var printObj = {
            base64Image: b64Image
            width: 500,
            brightness: 50,
            alignment: cordova.plugins.BixolonPrinting.ALIGNMENT.CENTER,
        };

        // Perform printing
        cordova.plugins.BixolonPrinting.printBitmap(
            function(res) { 
                alert("SUCCESS"); 

                // ... Do other things or just disconnect()
            }, 
            alertError, 
            printObj
        );
    },
    alertError,
    connection
);

Appendix

Constants

Device Bus

{
    BLUETOOTH: 0,
    ETHERNET: 1,
    USB: 2,
    WIFI: 3,
    WIFI_DIRECT: 4
};

Alignment

{
    ASIS: -11,
    LEFT: -1,
    CENTER: -2,
    RIGHT: -3
};

Device Bus Address

Device bus Address
BLUETOOTH BT MAC address
ETHERNET IP address
USB None
WIFI IP address
WIFI_DIRECT WLAN MAC address

Credits

License

This software is released under the Apache 2.0 License.

cordova-plugin-bixolon-printing's People

Contributors

itskaynine avatar

Watchers

 avatar  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.