electron-pos-printer
electron-pos-printer copied to clipboard
找不到 dist_electron/pos.html 文件
我在主进程中进行调用,但是失败了,找不到pos.html文件
我在包里有看到pos.html文件,但在自动生成的打dist文件里面没有pos.html文件,是否与我用的是JavaScript而不是typeScript有关?
你好, 我为我迟到的回复道歉,我会尽快查看。 我正在努力使其与最新版本的电子兼容。 感谢您使用此软件包
@Hubertformin could you please publish the latest code to npm....
Hello @janafsal I just did!
after update it don't prints, please see the above screenshot of preview window, could you please check?...thanking you in advance
@janafsal Can you share the snippet of your code?
const { PosPrinter } = require("electron-pos-printer");
printerName="Microsoft Print to PDFline 361"
data = [
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: "||---",
style: `text-align:left;`,
css: { "font-size": "12px",'margin':'0' },
},
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: "hello world",
style: `text-align:center;`,
css: { "font-weight": "700", "font-size": "18px","margin-top":"5px","text-decoration":"underline",'margin':'0'},
}]
const options = {
preview: true, // Preview in window or print
width: "250px", // width of content body
margin: "0 0 0 0", // margin of content body
copies: 1, // Number of copies to print
printerName: printerName, // printerName: string, check it at webContent.getPrinters()
timeOutPerLine: 400,
silent: true,
};
const d = [...data];
PosPrinter.print(d,options)
.then(() => {
// console.log('printed successfully')
// const notification= new Notification({title:'Success',body:'Printed successfully'})
// notification.show()
})
.catch((error) => {
// console.error(error);
const dialogOpts = {
type: 'error',
buttons: [],
title: 'Print Error',
message: error,
detail:
'error occured during the print job please contact administrator',
}
dialog.showMessageBox(dialogOpts).then((returnValue) => {
})
});
Some major updates were done to styling, the css property is no longer supported. Please use style. style
takes an object.
Using your example, look at the code below
const d = [
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: "||---",
style: {textAlign: 'left', fontSize: "12px", 'margin': '0'},
},
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: "hello world",
style: {
textAlign:`center`,
fontWeight: "700",
fontSize: "18px",
marginTop: "5px",
textDecoration: "underline",
margin: '0'
},
}
]

Some major updates were done to styling, the css property is no longer supported. Please use style.
style
takes an object.Using your example, look at the code below
const d = [ { type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value: "||---", style: {textAlign: 'left', fontSize: "12px", 'margin': '0'}, }, { type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table value: "hello world", style: { textAlign:`center`, fontWeight: "700", fontSize: "18px", marginTop: "5px", textDecoration: "underline", margin: '0' }, } ]
![]()
thank you so much now its working.... so the style properties will be camel cased of css properties right?
@janafsal Yes, exactly. Just like writing styles in jsx
@janafsal Yes, exactly. Just like writing styles in jsx
Noted with thanks…
May I ask if it is compatible with Electron
@BoxCode7, This is compatible with the latest version of electron.
Although I have changed to other schemes, I still appreciate it very much. I will definitely use it again when I have the chance!