# Load PDF Viewer in popup

**URL:** <https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [March 26, 2020, 12:27pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428 "2020-03-26T12:27:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 26, 2020, 12:27pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428/1 "2020-03-26T12:27:45Z")

</div>

I’m storing data/BLOB in MySQL to view PDFs. I can easily get things to work if the PDF Viewer is in the window where I’m ‘calling’ the database.

```auto
event.source.parent.getComponent('PDF Viewer').loadPDFBytes(bytes,name)

```

But, what if I want this viewer in a popup? How do I pass the values? I tried creating custom properties of string type but that didn’t work. Can someone push me in the right direction?

FYI, I was using internalFrameActivated…

```auto
name = system.gui.getParentWindow(event).getComponentForPath('Root Container').FileName
bytes = system.gui.getParentWindow(event).getComponentForPath('Root Container').Bytes
system.gui.getParentWindow(event).getComponentForPath('Root Container.PDF Viewer').loadPDFBytes(bytes, name)

```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [March 26, 2020, 12:48pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428/2 "2020-03-26T12:48:38Z")

</div>

You can set custom properties on the root container of your pop up - these will be parameters you can pass in.

Then you can do something like

`system.nav.openWindow("Pop_OpenWindow", {"param1":value, "param2":value,..})`

[https://docs.inductiveautomation.com/display/DOC79/system.nav.openWindow](https://docs.inductiveautomation.com/display/DOC79/system.nav.openWindow)

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 26, 2020, 1:01pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428/3 "2020-03-26T13:01:12Z")

</div>

I’m not asking how to pass parameters, that’s simple, what I’m asking is passing bytes to the PDF Viewer. Using string data type didn’t work.

Edit: FileName & Bytes are my custom properties…

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [March 26, 2020, 1:06pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428/4 "2020-03-26T13:06:21Z")

</div>

My fault. So you’re passing the entire bytes as a paramter and then do `system.gui.getParentWindow(event).getComponentForPath('Root Container').Bytes`? I think you’re better off just passing in the id of the row in the db that you want, and then in the internalFrameActivated, querying for the blob data and doing everything there. I wouldn’t try to pass bytes or blob data via paramter.

---

<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:** [March 26, 2020, 1:14pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428/5 "2020-03-26T13:14:10Z")

</div>

There’s no (reliable) way to store raw bytes directly in a Vision custom property. The only supportable way would be to define a Dataset property, and pass the bytes in a 1Rx1C dataset.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 26, 2020, 1:19pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428/6 "2020-03-26T13:19:07Z")

</div>

Thanks, not sure why I didn’t think of that. Appreciate the push!!

---

<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:** [March 26, 2020, 1:35pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428/7 "2020-03-26T13:35:57Z")

</div>

Nit to pick: Y’all are doing this in a window event:

```auto
b = system.gui.getParentWindow(event).getComponentForPath('Root Container').Bytes

```

But a window event’s source is the window, and a window has a rootContainer property. This is far more readable (and faster):

```auto
b = event.source.rootContainer.Bytes

```

The property and tag lookup helpers in the script editor have no concept of optimizations or temporary variables or use of event properties. You shouldn’t treat their generated code as gospel.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [March 26, 2020, 1:38pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428/8 "2020-03-26T13:38:18Z")

</div>

I personally never knew we could still use event.source in window events, I thought the system.giu.getParentWindow stuff was necessary since the property lookup always used it. Good to know! Why the difference in syntax if we can still just use event.source?

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 26, 2020, 1:51pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428/9 "2020-03-26T13:51:17Z")

</div>

Nit pick away, I’m always up for learning something better. I’ll admit, I’m lazy and just the let the software do the path for me.

---

<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:** [March 26, 2020, 2:53pm UTC](https://forum.inductiveautomation.com/t/load-pdf-viewer-in-popup/33428/10 "2020-03-26T14:53:42Z")

</div>

> [@bkarabinchak.psi](#):
>
> Why the difference in syntax

The property/tag pickers are not context sensitive. They don't "know" what kind of event they are working in.

You should also consider, when dealing with multiple properties of a selected component, to store the component in a temporary variable in the script. Then multiple operations can be done with its properties without "getting" it every time.
