dsandor / dymojs

A pure javascript library for printing labels on a Dymo Labelwriter printer from the browser or from nodejs.
128 stars 30 forks source link

Use case/update #24

Open rreis27 opened 9 months ago

rreis27 commented 9 months ago

I found after some testing with the latest version of the Dymo Connect Service (installed with DCDSetup1.4.4.1.exe) that you need to call getPrinters() prior to attempting to print. I was using VisitorManagement javascript sample in the DYMO DCD-SDK-Sample-master javascript and found that it works using the dymo.connect.framework.full.js. I did some analyzing of the code and found that when the DOM loads it calls the dymo.label.framework.getPrintersAsync(). I incorporated the call to getPrinters(), but in doing so I also modified it to be an async call. I've included the minimal changes below. I hope this helps someone else.

    async getPrinters() {
    if (typeof process !== 'undefined' && process.env) {
        process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; // TODO: Bundle the certificates.
    }

    await fetcher(`${this.apiUrl}/GetPrinters`)
        .then((response) => response.text());
}
seniorramirez commented 6 months ago

Love u bro! I had been looking for a way to make it work for a while, and the solution was the right one. thank you!