# PDF Viewer & Event Handlers

**URL:** <https://forum.inductiveautomation.com/t/pdf-viewer-event-handlers/26795>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [July 23, 2019, 12:52pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-event-handlers/26795 "2019-07-23T12:52:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FLi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/fli/32/10076_2.png) [@FLi](https://forum.inductiveautomation.com/u/FLi)\
**Post date:** [July 23, 2019, 12:52pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-event-handlers/26795/1 "2019-07-23T12:52:24Z")

</div>

Hello everyone,  
I want to retrieve the active PDF page of the PDF Viewer component. I’ve already done this inside a script of a button:

```auto
target = event.source.parent.getComponent('PDF Viewer')
swingController = target.getController()
event.source.parent.getComponent('random_label').text = str(swingController.getCurrentPageNumber())

```

My objective was to get the page number on the event “mouseClick”. However I have the feeling that none of the events are “triggered” within this component.  
First I tought I had done something wrong so I just put:

```auto
print "mouse clicked :)"

```

In the event handler “mouseClicked” of the PDF Viewer component. Unfortunately I don’t see anything in the console output even after clicking several times. (I’ve tested other event handlers and none of them seem to work).

PS: I’m on Ignition 7.9.12.

---

<div class="post-metadata">

**Author:** ![jlivingston](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@jlivingston](https://forum.inductiveautomation.com/u/jlivingston)\
**Post date:** [July 23, 2019, 5:21pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-event-handlers/26795/2 "2019-07-23T17:21:55Z")

</div>

Here is some recent forum activity that may be of use:

> [@PDF report linking](http://forum.inductiveautomation.com/t/pdf-report-linking/18860/3):
>
> Hello Paul, Thank you so much for spending time on this, I really do appreciate it. In fact its what’s so great about Ignition that we have this community. I will definitely give this a bash and let you know how I get along. It’s certainly going to make the reporting that much more powerful for us.

and  
ignitionusermanualexport.zip\doc79\pdf-viewer\_8227280.html (this assumes you downloaded the manual )  
Finally, if you are in a hurry, you may wish to first check out the policies, then send an e-mail or call starting at the following link: [https://support.inductiveautomation.com](https://support.inductiveautomation.com)  
I hope this helps... it gave me some understanding about the IA Labs PDF Viewer module ( now deprecated ).

---

<div class="post-metadata">

**Author:** ![FLi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/fli/32/10076_2.png) [@FLi](https://forum.inductiveautomation.com/u/FLi)\
**Post date:** [July 24, 2019, 8:37am UTC](https://forum.inductiveautomation.com/t/pdf-viewer-event-handlers/26795/3 "2019-07-24T08:37:04Z")

</div>

Thanks but the topic is not related to my problem. My hyperlinks into PDF are working and I don’t need to create one.  
I just want to know why the event handlers doesn’t work with the PDF Viewer component. And how to overcome this?  
I know the PDF component is coming from ICEpdf and there’s an action listener in the swingcontroller: [http://res.icesoft.org/docs/icepdf/v4\_3\_2/viewer/javadocs/org/icepdf/ri/common/SwingController.html](http://res.icesoft.org/docs/icepdf/v4_3_2/viewer/javadocs/org/icepdf/ri/common/SwingController.html)  
So I hope there’s an explanation and solution …

---

<div class="post-metadata">

**Author:** ![FLi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/fli/32/10076_2.png) [@FLi](https://forum.inductiveautomation.com/u/FLi)\
**Post date:** [July 30, 2019, 9:01am UTC](https://forum.inductiveautomation.com/t/pdf-viewer-event-handlers/26795/4 "2019-07-30T09:01:35Z")

</div>

> [@FLi](#):
>
> I just want to know why the event handlers doesn’t work with the PDF Viewer component. And how to overcome this?

I thought it was a trivial question: Are events like “mouseClick” functional on the PDF Viewer component? 😞

---

<div class="post-metadata">

**Author:** ![Dilan](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@Dilan](https://forum.inductiveautomation.com/u/Dilan)\
**Post date:** [July 31, 2019, 8:08pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-event-handlers/26795/5 "2019-07-31T20:08:16Z")

</div>

Hello,

Hope this helps, for the hyperlinks I’ve made they do work on on both the PDF Viewer Component and within adobe acrobat, I’m currently on 7.9.10.

---

<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:** [July 31, 2019, 8:43pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-event-handlers/26795/6 "2019-07-31T20:43:10Z")

</div>

The PDF viewer component is our integration of an “off the shelf” library. Without investigating it too far, it’s likely that we aren’t doing the required shenanigans in Java Swing to allow custom mouse events to fire. That _might_ just be an oversight, but it’s equally possible that it’s not possible to introduce custom mouse event handlers without breaking the actual component. Again - I don’t know for sure, but there’s a decent chance that’s the case. I would recommend getting in contact with support to see if there’s a workaround (maybe overlaying a transparent label, and intercepting mouse events on it?) or so that they can file a bug ticket if this indeed is something we can simply implement.

---

<div class="post-metadata">

**Author:** ![FLi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/fli/32/10076_2.png) [@FLi](https://forum.inductiveautomation.com/u/FLi)\
**Post date:** [August 1, 2019, 7:03am UTC](https://forum.inductiveautomation.com/t/pdf-viewer-event-handlers/26795/7 "2019-08-01T07:03:06Z")

</div>

> [@paul-griffith](#):
>
> The PDF viewer component is our integration of an “off the shelf” library. Without investigating it too far, it’s likely that we aren’t doing the required shenanigans in Java Swing to allow custom mouse events to fire. That _might_ just be an oversight, but it’s equally possible that it’s not possible to introduce custom mouse event handlers without breaking the actual component. Again - I don’t know for sure, but there’s a decent chance that’s the case. I would recommend getting in contact with support to see if there’s a workaround (maybe overlaying a transparent label, and intercepting mouse events on it?) or so that they can file a bug ticket if this indeed is something we can simply implement.

Thanks a lot that's the confirmation of my observations.

I already tested to put a transparent control in front of my PDF but it doesn't work and moreover since I click on the control and not on the PDF Viewer the hyperlink is not triggered.

I've already opened a support ticket, they ask me ton install TeamViewer to get a remote access to check my code... It's not a question of checking my code, because I've tested the event with just a print ...

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [August 6, 2019, 8:05pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-event-handlers/26795/8 "2019-08-06T20:05:30Z")

</div>

Mouse events seem to work if I click on the border of the PDF Viewer component. Could you somehow make use of this in your application?
