# Print to Image

**URL:** <https://forum.inductiveautomation.com/t/print-to-image/4767>\
**Category:** Ignition\
**Created:** [July 5, 2012, 1:07pm UTC](https://forum.inductiveautomation.com/t/print-to-image/4767 "2012-07-05T13:07:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 5, 2012, 1:07pm UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/1 "2012-07-05T13:07:33Z")

</div>

I would like to print to Image an Active X (IE) window.

All works except the Active X (IE) is Blank.

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [July 5, 2012, 4:54pm UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/2 "2012-07-05T16:54:21Z")

</div>

What version of Ignition are you using?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 5, 2012, 6:13pm UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/3 "2012-07-05T18:13:05Z")

</div>

Java and ActiveX are like my kids: they don’t play very nicely with each other. Is it something that can be displayed outside of using an ActiveX?

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 5, 2012, 6:15pm UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/4 "2012-07-05T18:15:48Z")

</div>

I want to take a snap shot of a webpage every 15 minutes

Version 7.2.11

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 5, 2012, 8:04pm UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/5 "2012-07-05T20:04:59Z")

</div>

Yeah, this is definitely one of those “not play together” issues. I’ve tried a couple of different ways with no go.

Would you be able to use an httpGet and parse your stuff out the html you get back?

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [July 6, 2012, 12:15am UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/6 "2012-07-06T00:15:52Z")

</div>

If you feel like getting your hands dirty, you might be able to use your handy mechanical friend, java.awt.robot, to do this for you.

Note: This is pretty advanced, as it digs into the Java API.

Full Code:

```auto

# Capture Test

from java.awt import Robot, Toolkit, Rectangle
from java.io import File
from javax.imageio import ImageIO

robot = Robot()
toolkit = Toolkit.getDefaultToolkit()
dimension = toolkit.getScreenSize()
bufferedImage = robot.createScreenCapture(Rectangle(0, 0, dimension.width, dimension.height))

filepath = system.file.saveFile("screenshot.png", "png", "png file")

if filepath is not None:
	file = File(filepath)
	if ImageIO.write(bufferedImage, "png", file):
		system.gui.messageBox("Image saved.")
	else:
		system.gui.messageBox("Image write failed.")

```

If you want just a part of your screen, you could take the bufferedImage and manipulate it before saving. (or you could pass a different Rectangle to robot.createScreenCapture())

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 6, 2012, 2:52am UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/7 "2012-07-06T02:52:53Z")

</div>

Kevin

Your code worked good!

Now I want to put it on a Ignition Timer (15 minutes or so), so i don’t want the save box to pop open, I want to hard code the save to path . such as ( c:\screenpic\Screenshot.png).

Then every 15 minutes or so I will have a refreshed Screenshot.png, which will open in a Doc Viewer on some client PC’s that don’t have internet access.

Is it possible for the screeshot to just be a Ignition container ?

Thanks for your Help !

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 6, 2012, 11:32am UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/8 "2012-07-06T11:32:18Z")

</div>

Wow! Kevin, you got my mind a-runnin'! 😆

This will save just the component (I called mine IEViewer for just the ActiveX Control, but you can use whatever component you wish.)

Reading deeper into the API let me come up with getLocationOnScreen() and getBounds() to define the rectangle for the createScreenCapture().

Jerry, this will also directly save the screencap.

Hope this helps!

[code]# Capture Test

from java.awt import Robot, Rectangle  
from [java.io](http://java.io) import File  
from javax.imageio import ImageIO

robot = Robot()

location=event.source.parent.getComponent('IEViewer').getLocationOnScreen()  
bounds=event.source.parent.getComponent('IEViewer').getBounds()

rect=Rectangle(location.x, location.y, bounds.width, bounds.height)

bufferedImage = robot.createScreenCapture(rect)

file = File("C://screenpic/Screenshot.png")  
ImageIO.write(bufferedImage, "png", file)[/code]

> [@Kevin.McClusky](#):
>
> ...you might be able to use your handy mechanical friend, java.awt.robot, to do this for you.

Reminds me of the line from Hitchhiker's Guide to the Galaxy: "Your plastic pal who's fun to be with!"

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 6, 2012, 1:06pm UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/9 "2012-07-06T13:06:41Z")

</div>

Jordan

Code worked Great !

Thanks for your Help !

This would be good to add to the Users manual !

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 6, 2012, 1:32pm UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/10 "2012-07-06T13:32:19Z")

</div>

Well, that sort of stuff is already documented in the javadocs. To put everything in the User manual would be a bit redundant-- not to mention potentially dangerous-- not that I’ve ever done anything like that… just what I’ve heard… from others… 😆

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 6, 2012, 1:37pm UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/11 "2012-07-06T13:37:38Z")

</div>

Just to give you an idea, here’s the link to the Java API docs.

[http://docs.oracle.com/javase/6/docs/api/](http://docs.oracle.com/javase/6/docs/api/)

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 6, 2012, 1:44pm UTC](https://forum.inductiveautomation.com/t/print-to-image/4767/12 "2012-07-06T13:44:57Z")

</div>

Thanks I am sure this will be useful.
