# Printing Container from Script Overwrites Driver Settings

**URL:** <https://forum.inductiveautomation.com/t/printing-container-from-script-overwrites-driver-settings/88647>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [April 10, 2024, 3:25pm UTC](https://forum.inductiveautomation.com/t/printing-container-from-script-overwrites-driver-settings/88647 "2024-04-10T15:25:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Thamm](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@Michael\_Thamm](https://forum.inductiveautomation.com/u/Michael_Thamm)\
**Post date:** [April 10, 2024, 3:25pm UTC](https://forum.inductiveautomation.com/t/printing-container-from-script-overwrites-driver-settings/88647/1 "2024-04-10T15:25:40Z")

</div>

**System Info** :

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

**Printer Driver Settings** :

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/a/1af625ba105f70c1a2961649e1657a1f2ca4f1d8.png)

**Ignition Script** :

```auto
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:

```auto
('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](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/c/8c984fed0eb7a6e395bc983f61deb458aa22a6a7.png)  
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](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/2/021f471365c471e8d8833aaf3a86aa6b14da1eef.png)

**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](https://forum.inductiveautomation.com/t/printing-from-report-module-offset/48611). 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?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 10, 2024, 3:55pm UTC](https://forum.inductiveautomation.com/t/printing-container-from-script-overwrites-driver-settings/88647/2 "2024-04-10T15:55:48Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![Michael\_Thamm](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@Michael\_Thamm](https://forum.inductiveautomation.com/u/Michael_Thamm)\
**Post date:** [April 17, 2024, 4:59pm UTC](https://forum.inductiveautomation.com/t/printing-container-from-script-overwrites-driver-settings/88647/3 "2024-04-17T16:59:22Z")

</div>

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.
