Generate barcode component from the gateway context

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!!

No, none of the Swing-based user interface classes are present in the gateway. This is the primary reason the Reporting module was rebuilt from scratch – generating reports from the gateway needed an independent set of graphical objects. Consider using the Reporting module to produce your barcode.

Thank you for your answer. I think I’ll just try to run the script in the client as we don’t have a license for the Reporting Module.

There are also several webservices out there that can generate barcodes. You could call a web service and it would return an image of the barcode for you to use. Also, if you are printing to a label printer, you can usually send code directly to the printer to print barcodes… Lots of options here depending on your architecture.