-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo1.js
24 lines (18 loc) · 802 Bytes
/
demo1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const {DymoServices, createImageWithText} = require('node-dymo-printer');
/**
* Try to find the DYMO LabelWriter and print "Hello World!" on a 89mm x 36mm label.
*/
(async function () {
// Create landscape image with the dimensions of the label and with the text "Hello World!".
const {imageWidth, imageHeight} = DymoServices.DYMO_LABELS['89mm x 36mm'];
const image = await createImageWithText(imageWidth, imageHeight, 50, 128, 'Hello World!');
// For debugging purposes, write the image to disk.
image.write(__dirname + '/image1.png');
// Print it, just one label.
try {
await new DymoServices().print(image, 1);
console.log('Successfully printed');
} catch (e) {
console.error('Error while trying to print the image: ', e);
}
})();