An Electron Node.js module for interacting with Dymo LabelWriter printers using the DLS SDK. This library is built and maintained by Paul Prins of Fresh Vine for their Event Kiosk.
The documentation for the SDK is located in the SDK sample file from DYMO. You can download it from here.
You will need the latest Dymo LabelWriter software installed first. This provides all of the dependent Dymo libraries.
$ npm install printer-dymo --save
This impementation is still very young but is production ready.
var printerDymo = require('printer-dymo'),
fs = require('fs');
// It takes a second or two for initialization to complete.
setTimeout(function(){
// Gets an array of IPrinter objects (Dymo printers on the current system)
printerDymo.getPrintersAsync(null, function(err, printers){
if (err) throw err;
console.log(printers);
});
// A print object;
var printArgs = {
printer: 'DYMO LabelWriter 450', //name of printer
jobTitle: 'My Sweet Labels',
labels:[{
filename: 'test.label', //path to label
fields: {
name: 'Timmy',
barcode: '100360931'
},
images: {
photo: fs.readFileSync('face.png')
}
}]
};
printerDymo.print(printArgs, function(err, res){
if (err) throw err;
console.log("Finished Printing.");
});
}, 2000);
Prerequisits:
Install Node.js. Then install gyp:
$ npm install -g node-gyp
For gyp you will also need:
To get the DLLs to include in the project you need to install the DLS software from DYMO. The 32 bit versions are placed into the base install directory (c:\Program Files (x86)\DYMO\DYMO Label Software), and the 64 bit versions are in the x64 folder off that base directory. Beyond that there is a DYMO.Label.Framework.dll
file located in the 'Framework' directory.
Whenever there is an update to the DYMO DLS we should update these libraries if there are any differences.
In order for the electron-edge-js library to work correctly the client computer must have the .NetFramwork 4.5 installed. So you can either require them to install this (which will likely just lead to higher support volume to explain this), or you can include the needed library items in your build.
To include the required DLLs you should download them from microsoft - download .NetFramework 4.5. You need 4 of these libraries (concrt140.dll, msvcp140.dll, vccorlib140.dll, vcruntime140.dll). Electron Builder makes it easy to use architecture in their extraFiles
(docs). The code below will grab every file in the extraLib/dotNetFramework/x64/
directory for an x64 build on windows, and place it in the application root directory. Using the dependency walker we were able to verify that the application utilized these files, instead of those on (or missing from) the client system.
{
...
"build": {
...
"files": [
"!**/extraLib/**/*"
],
"win": {
"extraFiles": [
{
"from": "extraLib/dotNetFramework/${arch}/",
"to": "",
"filter": "**/*"
}
]
}
...
}
...
}
We deploy to both x64 and ia32. Make sure the correctly build libraries are in the correct locations. Our paths look like:
extraLib/dotNetFramework/ia32/concrt140.dll
extraLib/dotNetFramework/ia32/msvcp140.dll
extraLib/dotNetFramework/ia32/vccorlib140.dll
extraLib/dotNetFramework/ia32/vcruntime140.dll
extraLib/dotNetFramework/x64/concrt140.dll
extraLib/dotNetFramework/x64/msvcp140.dll
extraLib/dotNetFramework/x64/vccorlib140.dll
extraLib/dotNetFramework/x64/vcruntime140.dll
These files are not included here to allow for flexibility in use. Also you may have other libraries that make use of this framework, and including it multiple times would add overhead to your project.
npm pack
npm publish
Fork, add unit tests for any new or changed functionality.
Lint and test your code.
electron-edge-js
from electron-edge
as it has wider support.DYMOPrinting.dll
& PrintingSupportLibrary.dll
) that caused errors when deployed. These are included with both x86 & x64 flavors.dymo.cs
to use dynamic variables in place of object variables.