Comments (3)
Hello. I have the same problem, but can't fix it... now i test with this package https://www.npmjs.com/package/escpos but return me another problem. One of the recommended solutions is to use Electron 12, I currently have version 13, I will be trying to downgrade to version 12 and try again... I am working on a project with:
VueJS, Express and Electron
node version 16.20 and npm version 8.19.4
from electron-pos-printer.
I found a solution and this is working for me now, but using another package for VueJS and Electron, this is the package https://www.npmjs.com/package/electron-pos-printer-vue/v/1.0.9 if you are using something like Vuejs and Electron i share my code example here:
<button @click="imprimir">Imprimir</button>
<HelloWorld msg="Welcome to Your Vue.js App" />
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
const { PosPrinter } = require('electron').remote.require("electron-pos-printer-vue");
//const path = require("path");
export default {
name: 'App',
components: {
HelloWorld
},
methods: {
async imprimir() {
const options = {
preview: false, // Preview in window or print
width: '170px', // width of content body
margin: '0 0 0 0', // margin of content body
copies: 1, // Number of copies to print
printerName: 'ImpresoraBarata', // printerName: string, check with webContent.getPrinters()
//printerName: 'EPSON TM-T88V Receipt', // printerName: string, check with webContent.getPrinters()
timeOutPerLine: 400,
pageSize: { height: 301000, width: 71000 }, // page size
silent: true
}
const data = [
{
type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: 'SAMPLE HEADING',
//style: `text-align:center;`,
style: ''
}, {
type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table'
value: 'Secondary text',
//style: `text-align:left;color: red;`,
style: ''
}, {
type: 'barCode',
value: 'HB4587896',
height: 12, // height of barcode, applicable only to bar and QR codes
width: 1, // width of barcode, applicable only to bar and QR codes
displayValue: true, // Display value below barcode
fontsize: 8,
}, {
type: 'qrCode',
value: 'https://github.com/Hubertformin/electron-pos-printer',
height: 55,
width: 55,
style: ''
}, {
type: 'table',
// style the table
style: '',
// list of the columns to be rendered in the table header
tableHeader: ['Animal', 'Age'],
// multi dimensional array depicting the rows and columns of the table body
tableBody: [
['Cat', 2],
['Dog', 4],
['Horse', 12],
['Pig', 4],
],
// list of columns to be rendered in the table footer
tableFooter: ['Animal', 'Age'],
// custom style for the table header
tableHeaderStyle: 'background-color: #000; color: white;',
// custom style for the table body
tableBodyStyle: 'border: 0.5px solid #ddd',
// custom style for the table footer
tableFooterStyle: 'background-color: #000; color: white;',
}, {
type: 'table',
style: '', // style the table
// list of the columns to be rendered in the table header
//tableHeader: [{ type: 'text', value: 'Animal' }, { type: 'image', path: path.join(__dirname, 'assets/logo.png') }],
// multi dimensional array depicting the rows and columns of the table body
tableBody: [
[{ type: 'text', value: 'Cat' }],
[{ type: 'text', value: 'Dog' }],
[{ type: 'text', value: 'Horse' }],
[{ type: 'text', value: 'Pig' }],
],
// list of columns to be rendered in the table footer
tableFooter: [{ type: 'text', value: 'Animal' }],
// custom style for the table header
tableHeaderStyle: 'background-color: #000; color: white;',
// custom style for the table body
tableBodyStyle: 'border: 0.5px solid #ddd',
// custom style for the table footer
tableFooterStyle: 'background-color: #000; color: white;',
},
]
PosPrinter.print(data, options)
.then(() => { })
.catch((error) => {
console.error(error);
});
try {
await PosPrinter.print(data, options);
console.log("Impresión exitosa");
} catch (error) {
console.error("Error al imprimir:", error);
}
},
},
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
`
from electron-pos-printer.
Ran into the same error. I inspected the node_modules/electron-pos-printer and it didn't have all the required files. Downgraded to 1.3.6 and it works just fine.
from electron-pos-printer.
Related Issues (20)
- Documents larger than the electron window do not print completely. HOT 3
- Sample: type text can be an html string HOT 1
- dist folder deleted HOT 5
- Cannot find module 'electron-pos-printer' or its corresponding type declarations. I am using nextron HOT 1
- version 1.3.7 have no dist folder in node modules , so it is throwing error, 1.3.6 works fine HOT 8
- [1092:0605/115531.410:ERROR:print_render_frame_helper.cc(2264)] Printing failed. HOT 17
- Paper Size Issue - Only in Ubuntu
- Length of label is really long and unable to shorten it.
- Can't configure the package using electron-vuejs
- Image width MINE type url can't work accurately.
- [Fix] - Silent Print not wokring. HOT 6
- Application remains running on the background after closing HOT 1
- Why is the connection always wrong
- How to align barcode to the center of the print HOT 2
- Please Fix the typo in the model
- Margin, table padding, default font HOT 1
- Not able to hide the Border between Row with type = TABLE HOT 3
- Pass custom html file to to pathTemplate HOT 1
- Thermal print is breaking to pieces (Multiple pages) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-pos-printer.