# Hide the print dialog but print barcode

**URL:** <https://forum.inductiveautomation.com/t/hide-the-print-dialog-but-print-barcode/14332>\
**Category:** Ignition\
**Created:** [May 17, 2017, 8:01pm UTC](https://forum.inductiveautomation.com/t/hide-the-print-dialog-but-print-barcode/14332 "2017-05-17T20:01:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [May 17, 2017, 8:01pm UTC](https://forum.inductiveautomation.com/t/hide-the-print-dialog-but-print-barcode/14332/1 "2017-05-17T20:01:00Z")

</div>

Here is the code I have on a button to print a barcode. The problem is that when I uncomment the setshowprintdialog(0) line, the print dialog goes away BUT so does the barcode when it is printed. Using a DYMO LabelWriter 450 Turbo printer if that makes a difference. Ignition 7.9.2

```auto
try:
	#Print the Barcode to a Label
	job = system.print.createPrintJob(event.source.parent.getComponent('Barcode'))
	job.setOrientation(0)
	job.setPrinterName("DYMO LabelWriter 450 Turbo")
	job.setPageHeight(40)
	job.setFitToPage(1)
	#job.setShowPrintDialog(0)
	job.print()

except:
	1

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 17, 2017, 11:27pm UTC](https://forum.inductiveautomation.com/t/hide-the-print-dialog-but-print-barcode/14332/2 "2017-05-17T23:27:43Z")

</div>

If you remove the try/except, is an error being generated when the script is run without the showPrintDialog() method?

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [May 18, 2017, 12:05pm UTC](https://forum.inductiveautomation.com/t/hide-the-print-dialog-but-print-barcode/14332/3 "2017-05-18T12:05:18Z")

</div>

No error, and I tried without the try except. I just get blank labels printing.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [May 18, 2017, 1:57pm UTC](https://forum.inductiveautomation.com/t/hide-the-print-dialog-but-print-barcode/14332/4 "2017-05-18T13:57:37Z")

</div>

Can you try printing to a standard paper printer first? If it prints there, it is most likely related to page setup / paper layout and the margins when sending to the label printer are cutting off the barcode.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [May 19, 2017, 7:54pm UTC](https://forum.inductiveautomation.com/t/hide-the-print-dialog-but-print-barcode/14332/5 "2017-05-19T19:54:30Z")

</div>

Thanks for the suggestion Ryan.

The barcode did print on the regular paper. I did not specify my page width and height and so the default was going in as 8.5 and 11 which was moving my image off of the label, but when I had the dialog it was using recommended settings from the driver. So I just measured the label and entered in the setPageWidth and height. I’m all set now. Thanks.
