# Automatic PDF Printing

**URL:** <https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700>\
**Category:** Ignition\
**Tags:** scripting, vision\
**Created:** [February 14, 2024, 4:50pm UTC](https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700 "2024-02-14T16:50:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carson\_Hunter](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@Carson\_Hunter](https://forum.inductiveautomation.com/u/Carson_Hunter)\
**Post date:** [February 14, 2024, 4:50pm UTC](https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700/1 "2024-02-14T16:50:23Z")

</div>

Hello! I am trying to set a screen to pop up and give the option to save as a pdf, I have the script that works but I am just not sure how to make this script run at a certain time of day, any help is much appreciated thank you!

```auto
	system.nav.openWindow("Analog Report1")
	obj = system.gui.getWindow("Analog Report1")
	printJob = system.print.createPrintJob(obj) 
	printJob.showPrintDialog = 0
	printJob.orientation = system.print.PORTRAIT
	printJob.leftMargin=.05
	printJob.rightMargin=.05
	printJob.topMargin=.05
	printJob.bottomMargin=.05
	printJob.print()

```

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 14, 2024, 5:02pm UTC](https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700/2 "2024-02-14T17:02:53Z")

</div>

Is the report being generated from Ignition's report module, or is it simply a loaded PDF?

---

<div class="post-metadata">

**Author:** ![Carson\_Hunter](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@Carson\_Hunter](https://forum.inductiveautomation.com/u/Carson_Hunter)\
**Post date:** [February 14, 2024, 5:06pm UTC](https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700/3 "2024-02-14T17:06:41Z")

</div>

It is printing a pdf from a screen in vision, I have just found that you can use something like the following code inside of a timer client event to force the screen to popup and give the user the option to save, do you know if it is possible to save the pdf without having someone come and type in the name of the pdf and save it manually?

```auto
curTime = system.date.format(system.date.now(),"HH:mm:ss")
					
if curTime == "12:03:00":
					
		system.nav.openWindow("Analog Report1")
		obj = system.gui.getWindow("Analog Report1")
		printJob = system.print.createPrintJob(obj) 
		printJob.showPrintDialog = 0
		printJob.orientation = system.print.PORTRAIT
		printJob.leftMargin=.05
		printJob.rightMargin=.05
		printJob.topMargin=.05
		printJob.bottomMargin=.05
		printJob.print()
		system.nav.closeWindow(obj)

```

---

<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:** [February 14, 2024, 5:15pm UTC](https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700/4 "2024-02-14T17:15:07Z")

</div>

> [@Carson\_Hunter](#):
>
> to save the pdf without having someone come and type in the name of the pdf and save it manually?

You are printing to a PDF "printer", which is outside Ignition. So, no.

You should use the Reporting Module to make PDFs.

---

<div class="post-metadata">

**Author:** ![Carson\_Hunter](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@Carson\_Hunter](https://forum.inductiveautomation.com/u/Carson_Hunter)\
**Post date:** [February 14, 2024, 5:15pm UTC](https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700/5 "2024-02-14T17:15:49Z")

</div>

Is there a different way to save as a pdf that would allow you to do this other than the reporting module?

---

<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:** [February 14, 2024, 5:36pm UTC](https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700/6 "2024-02-14T17:36:54Z")

</div>

PDF, no. You could render the window to a BufferedImage and save that image to a file.

---

<div class="post-metadata">

**Author:** ![Carson\_Hunter](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@Carson\_Hunter](https://forum.inductiveautomation.com/u/Carson_Hunter)\
**Post date:** [February 14, 2024, 5:42pm UTC](https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700/7 "2024-02-14T17:42:38Z")

</div>

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![Carson\_Hunter](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@Carson\_Hunter](https://forum.inductiveautomation.com/u/Carson_Hunter)\
**Post date:** [February 14, 2024, 6:03pm UTC](https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700/8 "2024-02-14T18:03:08Z")

</div>

So something like this?

```auto
curDate = system.date.format(system.date.now(),"MM:dd:yyyy")
system.nav.openWindow("Analog Report1")
obj = system.gui.getWindow("Analog Report1")
path="C:\\Users\\chunter\\Desktop\\Norcross Scripts\\Test\\Test.png"
			
			# If the path is not None...
if path != None:
			    #Save the file
	system.print.printToImage(obj, path)
			    
system.nav.closeWindow(obj)

```

Also, I tried to do something like this, but it did not allow the print to happen just stating "IIOException: Can't create an ImageOutputStream!" Is my formatting incorrect?

```auto
path="C:\\Users\\chunter\\Desktop\\Norcross Scripts\\Test\\"+curDate+"_Test.png"

```

---

<div class="post-metadata">

**Author:** ![Carson\_Hunter](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@Carson\_Hunter](https://forum.inductiveautomation.com/u/Carson_Hunter)\
**Post date:** [February 14, 2024, 6:38pm UTC](https://forum.inductiveautomation.com/t/automatic-pdf-printing/85700/9 "2024-02-14T18:38:15Z")

</div>

It completely slipped my mind that you cannot have colons in file names 😑
