Hi, I’m trying to print a barcode when a opc tag value changes. I want to trigger the print command from the gateway because that is where the printer is connected.
Currently this is the function I have and it runs fine on the client, however the class “com.inductiveautomation.factorypmi” is not available from the gateway context. ¿Is there any way to get the PMIBarcode class from the gateway context?
def printBarcode(code):
from com.inductiveautomation.factorypmi.application.components import PMIBarcode
#Creamos un componente de tipo PMIBarcode
codigoBarras = PMIBarcode()
#Definimos el tipo de codigo
codigoBarras.barcodeType=PMIBarcode.CODE128
#Asignamos el codigo
codigoBarras.code=code
#Tamano del componente
codigoBarras.setSize(400,150)
#Altura del codigo
codigoBarras.barcodeHeight=120
#Ancho de la barra mas estrecha
codigoBarras.narrowestBarWidth=3
#Mostramos el codigo numerico debajo del codigo de barras
codigoBarras.showText=1
#Ponemos el codigo negro y el fondo blanco
codigoBarras.foreground=(0,0,0)
codigoBarras.background=(255,255,255)
#Generamos el trabajo de impresion
job = system.print.createPrintJob(codigoBarras)
#Mostramos el dialogo de impresion
job.setShowPrintDialog(1)
#Ajustamos el componente a la pagina
job.setFitToPage(1)
#Formato apaisado
job.setOrientation(0)
#Orden de imprimir
job.print()
Thank you!!