Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork26
Direct printing from Browser
License
adenvt/recta
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Direct printing from Browser
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.
Recta need desktop software calledRecta Host, it serve all hardware connection and bridge with Browser via Websocket
- You need to installRecta Host on every host that will be used for print, checkouthere to more information.
Just include it like other JS library
...<scriptsrc="https://cdn.jsdelivr.net/npm/recta/dist/recta.js"></script>...
Recta support commonjs module, so if you using webpack for your project. you can easly using it like other module
- Install package
$ npm install --save recta
- Import in your code
// using CommonJSvarRecta=require('recta')// using ES6 styleimportRectafrom'recta'
<scripttype="text/javascript">// ...varprinter=newRecta('APPKEY','1811')functiononClick(){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>
Create a new Recta object, parameter:
- Key: APPKEY used to authentication with Host, You can see on yourRecta Host Configuration
- Port: port of host,default: 1811
open connection to printer host.
returnPromise
print text.
note: it automaticaly add linefeed(\n
) use.raw()
instead if you wouldn’t add linefeed.
set horizontal text align, parameter value can be:
- LEFT
- CENTER
- RIGHT
turn emphasized mode on / off,default: true
turn underline mode on / off, set2
for set 2-dot width underline,default: true
select character font'A'
or'B'
select print modes, parameter:
- font: select character font, value:
'A'
or'B'
,default:'A'
- emphasized: turn on / off emphasized / bold mode, value:
true
orfalse
,default:false
- doubleHeight: turn on / off double height mode, value:
true
orfalse
,default:false
- doubleWidth: turn on / off double width mode, value:
true
orfalse
,default:false
- underline: turn on / off underline mode, value:
true
orfalse
,default:false
cut paper, parameter:
- partial: if
true
execute partial cut (one point left uncut) else cut paper completely (full cut), value:true
orfalse
,default:false
- linefeed: add linefeed, value:integer,default: 4
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
set barcode height, value can be range: 1 ≤ n ≤ 255
add linefeed as much as n,default: 4
print raw text / buffer
send print command to printer.printer wouldn’t execute until you call this
send reset instruction to printer
return a sliced Buffer instance and clear buffer
returnBuffer
clear buffer
close connection to host
returnPromise
Fired upon successful connection
Fired upon disconnected
Fired when an error occurs
- 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
This project is licensed under the MIT License - see theLICENSE.md file for details
About
Direct printing from Browser
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.