Printing Container from Script Overwrites Driver Settings

System Info:

  • Ignition 8.1.33
  • SATOWS408 printer
  • Windows 11
  • SATO driver 8.4.11.27839

Printer Driver Settings:

Ignition Script:

PrintContainer = event.source.parent.getComponent('Print_Template')
isPrintEnabled = event.source.parent.getComponent('chkboxPrntEnable').selected
job = system.print.createPrintJob(PrintContainer)

def printSettings(job):
	print("Fit: ", job.isFitToPage())
	print("Zoom: ", job.getZoomFactor())
	print("Orientation: ", job.getOrientation())
	print("Page width: ", job.getPageWidth())
	print("Page height: ", job.getPageHeight())
	print("L margin: ", job.getLeftMargin())
	print("R margin: ", job.getRightMargin())
	print("T margin: ", job.getTopMargin())
	print("B margin: ", job.getBottomMargin())

def setSettings(job):
	job.setFitToPage(True)
	job.setOrientation(1)
	job.setPageWidth(4)
	job.setPageHeight(2)
#	job.setLeftMargin(0)
#	job.setRightMargin(0)
#	job.setTopMargin(0)
#	job.setBottomMargin(0)
	job.setMargins(0)

#job.setShowPrintDialog(0)
if isPrintEnabled:
	setSettings(job)
	printSettings(job)
	job.print()

Problem Description:
When I print a test page within the Windows 11 printer settings for Portrait and Portrait flipped (180 degrees) it is aligned to the label and works as expected. However, when I print the container from within Ignition I get strange results as follows:

  1. When I run the print job via the Ignition script and then check the Console results I get this result:
('Fit: ', True)
('Zoom: ', -1.0)
('Orientation: ', 1)
('Page width: ', 4.0)
('Page height: ', 2.0)
('L margin: ', 0.0)
('R margin: ', 0.0)
('T margin: ', 0.0)
('B margin: ', 0.0)
  • However, with Show Print Dialog enabled I see that the script values are overwritten:
    image
    This is bad because we need a programmatic solution with no user interaction.
  1. When I run the print job via the script, the label formatting is strange and when I check the printer driver settings after the print, the values changed and do not reflect any of the values in the script or my previous driver settings. This only happens when triggering a print from within Ignition!
    image

Final Thoughts:

  1. I have tried many combinations of other settings such as Fit To Page = False while manually setting the page dimensions as well as margins, zoom, orientation. The behavior does not seem predictable and is similar to this post Printing from Report-module, offset - Ignition - Inductive Automation Forum. The main difference being that this user was able to print from container and started to experience the same issues when printing from a report using the executeAndDistribute command.
  2. I have a feeling this is a driver issue and would like some insight whether this is an Ignition issue or the driver from SATO
  3. As a last resort the use of ZPL might be able to act as a workaround for this problem. What is the feasibility of this and will it be a generic solution where the printer model/maker can be readily swapped?

My one client using SATO printers use ZPL with direct printing via TCP channel. No printer device setup required in either Windows or Linux. (They also use Zebra printers, with identical code.)

2 Likes

The solution was to match the aspect ratio of the container being printed to the label size (i.e. 2:1 aspect ratio for a 4x2" label). Then the printer preferences needed to be set to the correct label dimensions. With these settings in place, there were no scripting overwrites required for the print job (besides hiding the Print Dialog).

Thank you @pturmel for the ZPL suggestion as it is currently the only solution we have for inverting the print to the label.