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

recta-qr

v2.0.3

Published

Direct Printing From Browser Include QRCODE - Modify Recta Package From adenvt/recta

Downloads

37

Readme

Recta

Direct printing from Browser

Build Status npm version

Introduction

Reason

I'm web developer, and get project to make some Point Of Sale (POS) software. I have trouble when i need print some receipt especially with POS printer, so i make this project.

How it work

Recta need desktop software called Recta Host, it serve all hardware connection and bridge with Browser via Websocket

How to use

Requirement

  • You need to install Recta Host on every host that will be used for print, checkout here to more information.

Standalone

Just include it like other JS library

...
<script src="https://cdn.jsdelivr.net/npm/recta/dist/recta.js"></script>
...

Using Webpack or Browserify

Recta support commonjs module, so if you using webpack for your project. you can easly using it like other module

  1. Install package
$ npm install --save recta
  1. Import in your code
// using CommonJS
var Recta = require('recta')
// using ES6 style
import Recta from 'recta'

Example

<script type="text/javascript">
  // ...
  var printer = new Recta('APPKEY', '1811')

  function onClick () {
    printer.open().then(function () {
      printer.align('center')
        .text('Hello World !!')
        .bold(true)
        .text('This is bold text')
        .bold(false)
        .underline(true)
        .text('This is underline text')
        .underline(false)
        .barcode('CODE39', '123456789')
        .cut()
        .print()
    })
  }
  // ...
</script>

API

Class

new Recta(key, port)

Create a new Recta object, parameter:

  • Key: APPKEY used to authentication with Host, You can see on your Recta Host Configuration
  • Port: port of host, default: 1811

Methods

.open()

open connection to printer host.

return Promise

.text('string')

print text.

note: it automaticaly add linefeed (\n) use .raw() instead if you wouldn’t add linefeed.

.align('align')

set horizontal text align, parameter value can be:

  • LEFT
  • CENTER
  • RIGHT

.bold(true|false)

turn emphasized mode on / off, default: true

.underline(true|false|2)

turn underline mode on / off, set 2 for set 2-dot width underline, default: true

.font('A'|'B')

select character font 'A' or 'B'

.mode(font, emphasized, doubleHeight, doubleWidth, underline)

select print modes, parameter:

  • font: select character font, value: 'A' or 'B', default: 'A'
  • emphasized: turn on / off emphasized / bold mode, value: true or false, default: false
  • doubleHeight: turn on / off double height mode, value: true or false, default: false
  • doubleWidth: turn on / off double width mode, value: true or false, default: false
  • underline: turn on / off underline mode, value: true or false, default: false

.cut(partial, linefeed)

cut paper, parameter:

  • partial: if true execute partial cut (one point left uncut) else cut paper completely (full cut), value: true or false, default: false
  • linefeed: add linefeed, value: integer, default: 4

.barcode(type, barcode, barcodeHeight)

print barcode, parameter

  • type: type of Barcode, value:
    • UPC-A
    • UPC-E
    • EAN13
    • EAN8
    • CODE39
    • ITF
    • CODABAR
    • CODE93
    • CODE128
  • barcode: content barcode, value: string
  • barcodeHeight: set barcode height (optional), value: integer

.barcodeHeight(height)

set barcode height, value can be range: 1 ≤ n ≤ 255

.feed(n)

add linefeed as much as n, default: 4

.raw(raw)

print raw text / buffer

.print()

send print command to printer. printer wouldn’t execute until you call this

.reset()

send reset instruction to printer

.flush()

return a sliced Buffer instance and clear buffer

return Buffer

.clearBuffer()

clear buffer

.close()

close connection to host

return Promise

Events

.on('open', function() {})

Fired upon successful connection

.on('close', function() {})

Fired upon disconnected

.on('error', function(error) {})

Fired when an error occurs

Contributing

  • Fork this repo
  • Clone your repo
  • Install dependencies
  • Checkout a feature branch
  • Feel free to add your features
  • Make sure your features are fully tested
  • Open a pull request, and enjoy <3

License

This project is licensed under the MIT License - see the LICENSE.md file for details