Difficulties configuring print job for Zebra ZD620

I’m working on a project that has a few old reports (pallet labels) created prior to the reporting module update in 7.8. These reports print fine on an inkjet printer when you manually right click on the report and choose ‘print’.

Our goal is to remove this manual step, and automatically print these reports on a Zebra ZD620 thermal sticker printer. The reports and the stickers are both 4x6 inches.

I have two separate problems preventing me from accomplishing this.

Problem 1:

I know this is a fairly common use case, but I’m having difficulty properly configuring the print job. I’m attempting to use the following code that’s suggested in other similar posts:

report = event.source.parent.getComponent(“Report Viewer”)
#set various options
report.print();

This prints, but at the component level so there are page numbers and the scaling % dropdown visible on the label. If I manually print via the right click context menu, everything is perfect. Is there any way to create the print job programmatically that behaves similar to the context menu printing? Or is it only possible to print the component via scripting?

Problem 2:

When I attempt to print the label to the Zebra, the orientation is initially wrong. Even setting report.orientation doesn’t change this. However, if I print to the inkjet first, then the Zebra after, everything prints correctly. This leads me to believe that certain inkjet printer settings carry over to the Zebra job. Looking at the page setup tab, it looks like the inkjet printer allows me to select a paper size, while the Zebra does not. Is there a way to determine what settings at being used on the inkjet job that might be absent from the Zebra job?

Inkjet shows paper size:
image
Zebra does not:
image

If I cannot find a solution, My plan B is to recreate the label in ZPL, but since the label actually does print correctly under certain circumstances, I’d rather not reinvent the wheel.

Thanks for your time.

I recommend going the ZPL route. I’ve done it with the reporting module and it’s never been ideal. You’ll have more control and flexibility by generating the ZPL at the script level and bypassing the report module all together.

2 Likes

I should add, I went through all of this with IA support over 1 year ago. Tried to use system.report.executeAndDistribute() and never printed correctly where as using the .print() function it would. Then had issues with print drivers on the Ignition gateway and overall was a mess trying to go with the reporting module.

I endorse converting to ZPL, and using a raw TCP socket to deliver the job. Been there, done that, happy customer.

Thanks for the help. I decided to take your guy’s advice and try the ZPL solution. I came up with a working example this morning using Zebra’s Zdesigner software. Currently I’m just finding/replacing string tokens to generate variable labels. Is there any benefit to saving the template on the printer itself and passing parameters? Or do you guys just do it with string operations?

I do all the templating in Ignition.

While Zebra has a ton of options for templating, I rarely find people using it. If the printer is ever swapped or changed, how do you ensure the template is on the new printer. Easier just to keep everything in Ignition and only worry about what IP address to send the ZPL data to.

I have the same problem with you before, I install the driver on the PC

  1. you should setPrintName
  2. if you want it directly print without popup a window, you should setPrintDialog =0
  3. you should change the parameter of set Orientation
  4. you should set the ZoomFactor
    the last but not least, the most import thing is the following two parameter
    PageHeight and PageWidth,that you should manual change it’s parameter to see what happen
    I have the experience the same parameter (Height and Width), different print will have different result

after you set the correct information , then you can use a button to trigger or make it working in a client scripting trigger by some tags

	job = system.print.createPrintJob(ui.parent.getComponent('print'))
	#job = system.print.createPrintJob(event.source.parent)		
	#job.setPrinterName('Cumtenn CTP-2200 Series')	
	job.setPrinterName('FX DocuPrint P378 db')	
	job.setShowPrintDialog(0)
	job.setPageHeight(12)
	job.setPageWidth(10)
	
	job.setBottomMargin(0.01)
	job.setTopMargin(0.01)
	job.setRightMargin(0.01)
	job.setLeftMargin(0.01)
	job.setOrientation(0)
	job.setZoomFactor(0.62)
	job.print()