2016-09-07 80 views
0

我嘗試使用Chrome中的Dymo打印機打印標籤。我使用javascript sdk。在鉻中找不到dymo打印機

只有當我找到我的腳本打印機,我得到以下控制檯日誌錯誤:

未捕獲無DYMO安裝打印機。安裝DYMO打印機。 我改變了像dymo網站說的設置。有誰知道如何從鉻打印?

當我用IE或Firefox做到這一點時沒有問題。

這是我的代碼:

<!DOCTYPE> 
<html> 
    <head> 
     <title>Sample DYMO Label Plug-In</title> 


<script src="http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js"></script> 
    <!-- your script second --> 
    <script> 




      function OnLoad() 
      { 
       //GetCurrentPlugin(); 
       GetDYMOPrinters(); 

       //GetPaperTray(); 
       //GetMRUList(); 
       //GetObjectNames(); 
       //GetLabelImage(); 
      } 


      function GetDYMOPrinters() 
      { 
       // alert(" Testing 1"); 

       var printers = dymo.label.framework.getPrinters(); 
       if (printers.length == 0) 
       throw "No DYMO printers are installed. Install DYMO printers."; 
       //alert("dfdsfd"); 
       var printerName = ""; 
       for (var i = 0; i < printers.length; ++i) 
       { 
        var printer = printers[i]; 
        if (printer.printerType == "LabelWriterPrinter") 
        { 
         printerName = printer.name; 
         break; 
        } 
       } 

      //var label = dymo.label.framework.open("MyText.label"); 
      label.SetObjectText("Text", "John Smith"); 

      //alert(" Testing 2"); // Here this alert also not working . 
      label.print("DYMO LabelWriter 310"); 
      } 
    </script> 

    </head> 
    <body onload="OnLoad()"><form action="" method="post" id="DYMOLabel"> 
     <center> 
     <h2>DYMO Label Example</h2> 
     <input type=button value="Get DYMO Printers" onClick="GetDYMOPrinters()"> 
    </center> 
    </form> 




    </body> 
</html> 
+0

鉻開發人員工具控制檯中的任何錯誤? –

+0

否,僅未讀取未安裝DYMO打印機。安裝DYMO打印機 – robind38

+0

你正在加載這個本地網頁,即'file:///'而不是'http://'? –

回答

0

對我來說,今天運行正常使用SDK 2.0,(我下載的.js到我的項目)

<script src="js/DYMO.Label.Framework.2.0.2.js"></script> 

,我讀了一個XML文件中的標籤定義,並打印:

var label = dymo.label.framework.openLabelXml(datosxml); 

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);