# How to know PDF is loaded?

**URL:** <https://forum.inductiveautomation.com/t/how-to-know-pdf-is-loaded/43723>\
**Category:** Ignition\
**Created:** [February 23, 2021, 12:58pm UTC](https://forum.inductiveautomation.com/t/how-to-know-pdf-is-loaded/43723 "2021-02-23T12:58:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [February 23, 2021, 12:58pm UTC](https://forum.inductiveautomation.com/t/how-to-know-pdf-is-loaded/43723/1 "2021-02-23T12:58:15Z")

</div>

Hi,  
I am using pdf viewer componant and I want to execute my code after PDF get loaded completely. How can I get that PDF is loaded. I cant see any event, there I will get to know PDF loaded or not. Now my code is executing before PDF load.  
Any idea?

---

<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 23, 2021, 2:13pm UTC](https://forum.inductiveautomation.com/t/how-to-know-pdf-is-loaded/43723/2 "2021-02-23T14:13:05Z")

</div>

You’ll have to use some Java methods within Jython in order to do this. Start Here [org.icepdf.core.events](http://res.icesoft.org/docs/icepdf/latest/core/index.html)

You want to probably look at `org.icepdf.core.events`, then `PageLoadingListener`

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [February 23, 2021, 3:34pm UTC](https://forum.inductiveautomation.com/t/how-to-know-pdf-is-loaded/43723/3 "2021-02-23T15:34:55Z")

</div>

Okay…But How PageLoadingListener is used in Ignition scripting?  
can you please guide?

---

<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 23, 2021, 4:09pm UTC](https://forum.inductiveautomation.com/t/how-to-know-pdf-is-loaded/43723/4 "2021-02-23T16:09:55Z")

</div>

I started a script to test, but I have little experience in Java. Someone else maybe able to get the script working.

```auto
if event.propertyName == 'filePath':
	import org.icepdf.core.events.PageLoadingEvent as PageLoadingEvent
	import org.icepdf.core.events.PageLoadingListener as PageLoadingListener
	
	ple = PageLoadingEvent(event.source)
	target = pageLoadingListener.get()
	
	if target.pageLoadingEnded(ple):
		system.gui.messageBox('Loading Complete')

```

It maybe much simpler to have your code called by `invokeLater()`. The script below will execute 1000ms after the filePath of the PDF viewer changes.

```auto
if event.propertyName == 'filePath':
	def myFunc():
		...
	system.util.invokeLater(myFunc,1000)

```

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [February 23, 2021, 4:27pm UTC](https://forum.inductiveautomation.com/t/how-to-know-pdf-is-loaded/43723/5 "2021-02-23T16:27:01Z")

</div>

okay… Thank you…  
I think it is in vision but I want it in perpsective.  
can I try with same way in perspective?

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [February 25, 2021, 12:25pm UTC](https://forum.inductiveautomation.com/t/how-to-know-pdf-is-loaded/43723/6 "2021-02-25T12:25:05Z")

</div>

Hi, I have tried this but it is throwing error like 'No icepdf module available '.  
I have downloaded this but no idea about How to import external java module in ignition.  
Can you please help on this?

---

<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 25, 2021, 1:08pm UTC](https://forum.inductiveautomation.com/t/how-to-know-pdf-is-loaded/43723/7 "2021-02-25T13:08:24Z")

</div>

I’d say that perspective isn’t using icePDF for the pdf component since perspective is based on html5 and CSS not a Java runtime like Vision. I don’t know much about Perspective, so I can’t really say where to start.

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [February 25, 2021, 1:24pm UTC](https://forum.inductiveautomation.com/t/how-to-know-pdf-is-loaded/43723/8 "2021-02-25T13:24:21Z")

</div>

okay.Thanks.
