inavvilva / modified-electron-pos-printer

4 stars 0 forks source link

Error TimedOut #1

Open ciberi-co opened 2 years ago

ciberi-co commented 2 years ago

main process I get TimedOut error

const {PosPrinter} = require("modified-electron-pos-printer");

function imprimir(info){ if(info.data){ var printerName var printerName = 'EPSON' var widthPage = "300px" console.log(printerName, widthPage);

const options = {
  preview: false, // Preview in window or print
  width: widthPage, //  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 now = {
  type: "text",
  value: "" + date(),
  style: `text-align:center;`,
  css: { "font-size": "12px", "font-family": "sans-serif" },
};

const d = [
  {
    type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
    value: info.data,
    style: `text-align:left;`,
    css: { "font-size": "12px" },
  }
];

if (printerName && widthPage) {
  PosPrinter.print(d, options)
    .then(() => {
      printerName = undefined;
      widthPage  = undefined;
      info = undefined;
      console.log('imprimiedo');
    })
    .catch((error) => {
      console.error(error);
    });
} else {
  alert("Select the printer and the width");
}

}

}

janafsal commented 2 years ago

go to node modules=>electron-pos-printer=>dist(folder) => need to edit pos-printer.ts and compile again (or) edit pos-printer.js directly.in line no.91 (new BrowserWindow) Add webPreferences: { nodeIntegration: true, contextIsolation: false, }

ciberi-co commented 2 years ago

thank you very much it works correctly

El mar, 6 sept 2022 a la(s) 03:21, janafsal @.***) escribió:

go to node modules=>electron-pos-printer=>dist(folder) => need to edit pos-printer.ts and compile again (or) edit pos-printer.js directly.in line no.91 (new BrowserWindow) Add webPreferences: { nodeIntegration: true, contextIsolation: false, }

— Reply to this email directly, view it on GitHub https://github.com/inavvilva/modified-electron-pos-printer/issues/1#issuecomment-1237817493, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2C5GNHZLRE4WG7HFWL4FY3V435H7ANCNFSM54MBNOGQ . You are receiving this because you authored the thread.Message ID: @.***>

Titella commented 1 year ago

With:

"electron": "^16.0.5", "modified-electron-pos-printer": "^1.3.12"

When running in dev environment it gives the following errors:

│ (node:120) electron: Failed to load URL: file:///C:/Projectes/printer-server/dist/main/node_modules/modified-electron-pos-printer/dist/pos.html with error: ERR_FILE_NOT_FOUND │
│ TimedOut

I added "contextIsolation: false" but still not working

janafsal commented 1 year ago

https://www.npmjs.com/package/electron-pos-printer

You can use the above package instead of modified-electron-pos printer as the package has been updated recently Read the documentation carefully as its styling has changed

Mogeiman commented 1 year ago

https://www.npmjs.com/package/electron-pos-printer

You can use the above package instead of modified-electron-pos printer as the package has been updated recently Read the documentation carefully as its styling has changed

I get the following error for the above module: Cannot find module 'electron-pos-printer' or its corresponding type declarations. I did install and import the package correctly. I am using nextron.

janafsal commented 1 year ago

npm install electron-pos-printer Check the link for docs https://www.npmjs.com/package/electron-pos-printer

If it is not solved, share the code or part of error while debugging