OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Unable to Print Label with Dymo LableWriter 450

  • Thread starter Thread starter Azhar Abbas
  • Start date Start date
A

Azhar Abbas

Guest
I'm using Laravel 10 now I try to Print label with Dymo LableWriter 450 with sdk but it give me CORS error can Anyone help me ?

Code:
function loadLabel() {
            if (dymo.label.framework) {
                dymo.label.framework.init(function() {
                    var labelXmlPath = '/Label1.dymo';

                    var xhr = new XMLHttpRequest();
                    xhr.open('GET', labelXmlPath, true);
                    xhr.onreadystatechange = function() {
                        if (xhr.readyState == 4) {
                            if (xhr.status == 200) {
                                var labelXml = xhr.responseText;

                                if (labelXml) {
                                    var label = dymo.label.framework.openLabelXml(labelXml);

                                    console.log('Label loaded successfully:', label);
                                    console.log('Label XML:', label.getLabelXml());

                                    if (label.isDCDLabel()) {
                                        console.log('This is a DCD label.');
                                    } else {
                                        console.log('This is not a DCD label.');
                                    }

                                                                   

                                    var printers = dymo.label.framework.getPrinters();
                                    if (printers.length == 0) {
                                        throw "No DYMO printers are installed. Install DYMO printers.";
                                    }

                                    var printerName = "";
                                    for (var i = 0; i < printers.length; ++i) {
                                        var printer = printers[i];
                                        if (printer.printerType == "LabelWriterPrinter") {
                                            printerName = printer.name;
                                            break;
                                        }
                                    }

                                    label.print(printerName);
                                } else {
                                    console.error(
                                        'Error loading label XML. The content is empty or undefined.');
                                }
                            } else {
                                console.error('Error loading label XML. HTTP status:', xhr.status);
                            }
                        }
                    };
                    xhr.send();
                });
            } else {
                console.error('DYMO Label Framework is not available.');
            }
        }

this is my code but it give me error how can I handle CORS please give me any solution . Any other sdk or any other solution with third party if anyone work with this

<p>I'm using Laravel 10 now I try to Print label with Dymo LableWriter 450 with sdk but it give me CORS error can Anyone help me ?</p>
<pre><code>function loadLabel() {
if (dymo.label.framework) {
dymo.label.framework.init(function() {
var labelXmlPath = '/Label1.dymo';

var xhr = new XMLHttpRequest();
xhr.open('GET', labelXmlPath, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var labelXml = xhr.responseText;

if (labelXml) {
var label = dymo.label.framework.openLabelXml(labelXml);

console.log('Label loaded successfully:', label);
console.log('Label XML:', label.getLabelXml());

if (label.isDCDLabel()) {
console.log('This is a DCD label.');
} else {
console.log('This is not a DCD label.');
}



var printers = dymo.label.framework.getPrinters();
if (printers.length == 0) {
throw "No DYMO printers are installed. Install DYMO printers.";
}

var printerName = "";
for (var i = 0; i < printers.length; ++i) {
var printer = printers;
if (printer.printerType == "LabelWriterPrinter") {
printerName = printer.name;
break;
}
}

label.print(printerName);
} else {
console.error(
'Error loading label XML. The content is empty or undefined.');
}
} else {
console.error('Error loading label XML. HTTP status:', xhr.status);
}
}
};
xhr.send();
});
} else {
console.error('DYMO Label Framework is not available.');
}
}
</code></pre>
<p>this is my code but it give me error how can I handle CORS please give me any solution . Any other sdk or any other solution with third party if anyone work with this</p>
 

Latest posts

M
Replies
0
Views
1
Meliodas Dragon
M
Top