Skip to content

Instantly share code, notes, and snippets.

@RohitSaroj
Created May 2, 2024 05:33
Show Gist options
  • Save RohitSaroj/ca0341da6abe965d752bf3fafac7c494 to your computer and use it in GitHub Desktop.
Save RohitSaroj/ca0341da6abe965d752bf3fafac7c494 to your computer and use it in GitHub Desktop.
webContents.getPrintersAsync() not returning printer list on Linux Mint Cinnamon 19.1
/*
This code snippet gets the printer list and then returns default printer in the event response
This piece of code was working in electron version 13.2.2 but not in 24.8.8 for Linux Mint Cinnamon 19.1
*/
win.webContents.getPrintersAsync().then((printers) => {
const defaultPrinters = printers?.filter((p) => p.isDefault);
if (printers.length > 0) {
event.reply(EVENTS.PRINTER.RESPONSE, defaultPrinters[0]);
}
win.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment