Search code examples
pythonqtprintingqwebview

Dymo Label Printer from QWebview?


I am attempting to use the Dymo example pages to print a label from a QWebview in a Python/Qt based application. The example works fine in a major browser (IE, FF, Chrome have been tested). However, when the example page is loaded in the QWebview, I get the following error:

DYMO.Label.Framework.js line 1: Error: DYMO Label Framework Plugin is not installed

I'm unsure why it would work fine in another browser, but not in the web view of my application. What is the proper way to get these Dymo examples to load into the webview?

This is the sample page that works in the major browsers by fails in the QWebview (You'll need a Dymo printer to print, but otherwise it'll load with an alert telling that no printers were found): http://labelwriter.com/software/dls/sdk/samples/js/PreviewAndPrintLabel/PreviewAndPrintLabel.html

When I load it in the webview, I don't even get the alert (which makes sense since the error above is found on line 1).


Solution

  • I spoke with the vendor and was told that this is not a supported use of their software. So, instead of using a QWebView, I used the win32com package to do this with Dymo's SDK. The code below uses the Dymo LabelWriter to print a single label with 1 variable field on it.

    from win32com.client import Dispatch
    
    labelCom = Dispatch('Dymo.DymoAddIn')
    labelText = Dispatch('Dymo.DymoLabels')
    isOpen = labelCom.Open('test.label')
    selectPrinter = 'DYMO LabelWriter 450'
    labelCom.SelectPrinter(selectPrinter)
    
    labelText.SetField('VAR_TEXT', 'QGJ2148')
    
    labelCom.StartPrintJob()
    labelCom.Print(1,False)
    labelCom.EndPrintJob()
    

    The StartPrintJob and EndPrintJob wrap the Print because it is faster according to the SDK notes.