grandchef / escpos-buffer Goto Github PK
View Code? Open in Web Editor NEWLibrary to generate buffer for thermal printers.
License: MIT License
Library to generate buffer for thermal printers.
License: MIT License
is there a possibility to run this on react?
can we add a changelog?
what are the breaking changes to v4 ?
writeValue
is deprecated, use the new method writeValueWithResponse
/writeValueWithoutResponse
https://github.com/grandchef/escpos-buffer/blob/main/src/connection/WebBluetooth.ts#L21C48-L21C48
deprecated:
new ones:
I have a printer model TM T20X from Epson, nothing happens with this function:
(async () => {
const model = new Model('TM-T20')
const connection = new InMemory()
const printer = await Printer.CONNECT(model, connection)
await printer.setColumns(56)
await printer.write('Simple Text *** ')
await printer.writeln('Bold Text -> complete line text.[]123456', Style.Bold)
await printer.writeln('Double Height', Style.DoubleHeight | Style.Bold, Align.Center)
await printer.writeln('Double Width', Style.DoubleWidth, Align.Center)
await printer.writeln('Áçênts R$ 5,00', Style.DoubleWidth | Style.DoubleHeight, Align.Center)
await printer.feed(6)
await printer.buzzer()
await printer.cutter()
await printer.drawer(Drawer.First)
process.stdout.write(connection.buffer())
})()
#8 In this pull request you support pngjs object to constructor. But when I try to give a pngjs object it throws an error. Your code not assume this object as an instance of PNG.
Is it possible to add a new version to NPM for the new WebUSB stuff?
Maybe this could also be something useful to go into Travis? For example, if you bump the version number it triggers a publish?
Olá Francimar, vi que aceita uma grande variedade de impressoras que usamos aqui no Brasil.
Minha dúvida é a seguinte, é possível de utilizar essa library conectando diretamente na porta serial da impressora?
Se sim, tem um exemplo de como fazer?
-- English
Hello Francimar, I saw that you accept a wide variety of printers that we use here in Brazil.
My question is, is it possible to use this library by connecting directly to the printer's serial port?
If so, do you have an example of how to do it?
Is this package able to be run on Ubuntu 22.04?
Is there a possibility to use it with react native?
Today pngjs and fs libs don't exist in react-native, maybe splitting the core into two libs, one that generates the coding part outside of the imaging part, should work.
What do you think of the idea?
have you made this package work with WebUsb and Windows ?
We tried using https://zadig.akeo.ie/ to enable WinUSB drivers, but it didn't worked
do you have any tips to make this work?
we have an escpos printer connected by USB
Doesn't look like the CI published this new version to NPM?
After the bitmap image drawing the next writeln()
command does not add a new line after the text.
But the second text is incorrectly placed directly after the first one.
writeln('line1.');
writeln('line2.');
draw(image);
writeln('line3.');
writeln('line4.');
line1.
line2.
[Image]
line3.line4.
I have found the incorrect ESC command in draw()
function after each bitmap line.
File: src/profile/index.ts
Current (incorrect implementation):
yield this.connection.write(Buffer.from('\x1BJ\x00', 'ascii'));
Should be 0x0A
only:
yield this.connection.write(Buffer.from('\x0A', 'ascii'));
escpos
I have tested my offered change. It corrects the issue on my side.
import React from 'react';
import { WebUSB } from 'escpos-buffer';
./node_modules/escpos-buffer/dist/graphics/Image.js:4:0
Module not found: Can't resolve 'fs'
Example
const model = new Model('TM-T20');
const connection = new InMemory();
const printer = await Printer.CONNECT(model, connection);
await printer.writeln('Awesome);
const buffer = connection.buffer()
How can I print a buffer to a real printer?
https://stackoverflow.com/a/41242622/2628278
use the first interface available instead of a fixed number
Hey there, great library, thanks for the work.
I can see that for now you have two connection types, do you plan to add others for network, bluetooth ...?
Also I was wondering how faisable it is to have a preview of the receipt. ie: connection=Image/PDF Do you know of any code able to do that ?
That would make the app much more attractive I think and would allow to print to other non escpos printers as a fallback
While testing this out I get:
Error: Failed to execute 'open' on 'USBDevice': Access denied.
Worked around this by installing the Zadig USB driver, but then I get:
ReferenceError: Buffer is not defined
Heya oh wonderful team 🤘
Just wanting to double check there was plans to release the new changes merged on Tuesday. Just to make sure it hadn't been forgotten - I've forgotten to do this many times myself haha!
Thanks for all your great collaboration 😊
Looks like the ESC/POS allows font sizes to go all the way up to 8x:
https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=34
It would be useful to have this functionality.
I am happy to put a PR in to address this - wanted to open this issue to discuss possible solutions.
Perhaps simply, the easy way would be to add to the Style
enum extra sizes for height and width, but that would probably bloat it out a bit and I'm not sure I am a fan of this solution.
Other ideas:
Height
and Width
enum - but then we would have to add those to method calls too which isn't idealFont
class - eg new Font('Font A', Height.Height8, Width.Width6)
or font.height = Height.Height8
or printer.font.width = Width.Width6
Setup dependabot + automerge to keep deps up to date
https://dev.to/daniloab/using-github-actions-to-improve-your-developer-experience-29n7
I cannot use bematech mp-4200 as a printer.
the problem happens in the function when trying to connect with the printer.
static async CONNECT(
_model: SupportedModel | Model,
connection: Connection,
): Promise<Printer> {
let model: Model;
if (typeof _model === 'string') {
model = new Model(_model);
} else {
model = _model;
}
await connection.open();
model.profile.connection = connection;
await model.profile.initialize?.();
return new Printer(model);
}
When calling const printer = await Printer.CONNECT(model, connection);
inside the CONNECT function, the open
await connection.open();
that comes from WebUsb has the param interface number with a fixed number of 0.
async open({
configuration = 1,
interface: interfaceNumber = 1,
}
then, it breaks returning the same error of this issue #29.
To try to fix it, my machine has 2 interfaces. The problem is that zero doesn't work. To get around I changed the node_modules directly to 1 and the open function worked
open({ configuration = 1, interface: interfaceNumber = 1 } = {}) {
Returning and following the CONNECT function, the problem is that when calling await model.profile.initialize?.();
nothing else happens.
It has no errors or warnings.
What could be the problem? Do you have any idea how to solve it?
ControlID not working with WebUSB
Error:
"error": {
"stack": "Error: Failed to execute 'claimInterface' on 'USBDevice': Unable to claim interface."
},
Printer information:
"device": {
"configuration": {
"configurationName": null,
"configurationValue": 1,
"interfaces": [
{
"alternate": {
"endpoints": [
{
"direction": "in",
"endpointNumber": 1,
"packetSize": 512,
"type": "bulk"
},
{
"direction": "out",
"endpointNumber": 1,
"packetSize": 512,
"type": "bulk"
}
]
},
"claimed": false,
"interfaceNumber": 0
},
{
"alternate": {
"endpoints": [
{
"direction": "in",
"endpointNumber": 3,
"packetSize": 10,
"type": "interrupt"
}
]
},
"claimed": false,
"interfaceNumber": 1
},
{
"alternate": {
"endpoints": [
{
"direction": "in",
"endpointNumber": 2,
"packetSize": 512,
"type": "bulk"
},
{
"direction": "out",
"endpointNumber": 2,
"packetSize": 512,
"type": "bulk"
}
]
},
"claimed": false,
"interfaceNumber": 2
}
]
},
"manufacturerName": "ControliD",
"productName": "Print iD - Impressora Térmica não Fiscal",
"vendorId": 12342,
"serialNumber": "120100/0085B9"
},
Printer image:
Olá Francimar, tudo bem?
Estou fazendo um probleminha em uma impressora Print ID com QRCode, e ela retorna um erro na hora de gerar a impressão.
Outra coisa é que a fonte da impressora está meio zoada, e com _ nos finais de linha.
Se precisar, posso ajudar na correção fornecendo acesso a impressora via suporte remoto.
--EDIT
Configurado como epson TM-T20 não acontece o erro.
--EDIT 2
Peguei a função qrcode da epson, e coloquei na controlid e resolveu!
index.ts:138 Uncaught (in promise) TypeError: QRCode.toBuffer is not a function
at ControliD.<anonymous> (index.ts:138)
at Generator.next (<anonymous>)
at tslib.es6.js:76
at new Promise (<anonymous>)
at Module.__awaiter (tslib.es6.js:72)
at ControliD.drawQrcode (index.ts:137)
at ControliD.<anonymous> (ControliD.ts:23)
at Generator.next (<anonymous>)
at tslib.es6.js:76
at new Promise (<anonymous>)
at Module.__awaiter (tslib.es6.js:72)
at ControliD.qrcode (ControliD.ts:22)
at Printer.<anonymous> (Printer.ts:71)
at Generator.next (<anonymous>)
at tslib.es6.js:76
at new Promise (<anonymous>)
at Module.__awaiter (tslib.es6.js:72)
at Printer.qrcode (Printer.ts:70)
at TestPrinter (print.js:119)
at Object.PrintReceipt (print.js:15)
at handleTapPix (index.js:155)
at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
at invokeGuardedCallback (react-dom.development.js:4056)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070)
at executeDispatch (react-dom.development.js:8243)
at processDispatchQueueItemsInOrder (react-dom.development.js:8275)
at processDispatchQueue (react-dom.development.js:8288)
at dispatchEventsForPlugins (react-dom.development.js:8299)
at react-dom.development.js:8508
at batchedEventUpdates$1 (react-dom.development.js:22396)
at batchedEventUpdates (react-dom.development.js:3745)
at dispatchEventForPluginEventSystem (react-dom.development.js:8507)
at attemptToDispatchEvent (react-dom.development.js:6005)
at dispatchEvent (react-dom.development.js:5924)
at unstable_runWithPriority (scheduler.development.js:468)
at runWithPriority$1 (react-dom.development.js:11276)
at discreteUpdates$1 (react-dom.development.js:22413)
at discreteUpdates (react-dom.development.js:3756)
at dispatchDiscreteEvent (react-dom.development.js:5889)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.