# PDF Viewer Dynamic

**URL:** <https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 1, 2024, 3:49pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056 "2024-08-01T15:49:04Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![Francisco\_Ochoa](https://avatars.discourse-cdn.com/v4/letter/f/e495f1/32.png) [@Francisco\_Ochoa](https://forum.inductiveautomation.com/u/Francisco_Ochoa)\
**Post date:** [August 6, 2024, 3:40pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056/21 "2024-08-06T15:40:44Z")

</div>

thanks for the support but i dont have this lvl for do it

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [August 6, 2024, 3:50pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056/22 "2024-08-06T15:50:08Z")

</div>

Based on your screenshot, the file is in OneDrive...why not obtain the URL for the file and put that in the source for the PDFViewer. Also, that script is to get a listing of files sorted by modified date which you would have to add to it to do something else that you need like getting the file names and modified dates and store them in a dataset to compare from what you previously had...then trigger some other action if there is a change in the dates...but you hard-coded 1 file. So, my question is...how often will this file be changing? Every minute, hourly, daily? You'll get the latest file when someone navigates to the view. Are you worried someone will stay on the view for days without refreshing?

---

<div class="post-metadata">

**Author:** ![Francisco\_Ochoa](https://avatars.discourse-cdn.com/v4/letter/f/e495f1/32.png) [@Francisco\_Ochoa](https://forum.inductiveautomation.com/u/Francisco_Ochoa)\
**Post date:** [August 6, 2024, 5:03pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056/23 "2024-08-06T17:03:22Z")

</div>

yeah the file is on a folder from PC , i dont have a URL

---

<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:** [August 6, 2024, 5:19pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056/24 "2024-08-06T17:19:14Z")

</div>

> [@Francisco\_Ochoa](#):
>
> i dont have a URL

You **need** a URL to display in Perspective. Full stop.

WebDev makes it possible to expose files **in the gateway** at desired URLs.

Making anything that reliably exposes files from a OneDrive is going to be a challenge. Don't do that.

---

<div class="post-metadata">

**Author:** ![Francisco\_Ochoa](https://avatars.discourse-cdn.com/v4/letter/f/e495f1/32.png) [@Francisco\_Ochoa](https://forum.inductiveautomation.com/u/Francisco_Ochoa)\
**Post date:** [August 6, 2024, 5:26pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056/25 "2024-08-06T17:26:18Z")

</div>

i was using both options , first i created for each file on Web Dev and the second on the folder of webserver because if the file has changes it will change on the View

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/b/8b3bb26c76b137f69bdd2cc58ab40b600e833178.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/b/0be66cbb62c4e43d80e87a909a6a7d022a5f2d07.png)

these options works good , but the folder on the webserver can be modified while the application is active.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/b/4bdf9bd345a7704fae1ba6bdac1892b5da4aa379.png)

---

<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:** [August 6, 2024, 5:30pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056/26 "2024-08-06T17:30:37Z")

</div>

Don't mount every file individually in WebDev. Write a script for a `doGet()` endpoint that receives a file name as a URL query parameter. Read that file (only from the storage folder) and deliver it. Scripted reads and delivery of file content won't hold the file open.

---

<div class="post-metadata">

**Author:** ![Francisco\_Ochoa](https://avatars.discourse-cdn.com/v4/letter/f/e495f1/32.png) [@Francisco\_Ochoa](https://forum.inductiveautomation.com/u/Francisco_Ochoa)\
**Post date:** [August 6, 2024, 5:51pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056/27 "2024-08-06T17:51:53Z")

</div>

im really sorry with you , but you have a example?? im new with this module i never had used it

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [August 6, 2024, 7:13pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056/28 "2024-08-06T19:13:06Z")

</div>

The manual describes it pretty well.

Start here:

> **[Web Dev | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/web-dev#python-resources)**
>
> The Web Dev module enables you to directly program against the web server inside the Ignition Gateway. Webpages can be built by hand using a combination of Python programming and static web resources such as images, CSS files, JavaScript files, and...

The rough structure of your `doGet()` method is going to be as follows:

```python
def doGet(request, session):
    #get filename from request['params'] (not sure if it needs to be manually URL-decoded, might need to add this step)
    #should also normalize the filename input to prevent funny business (directory traversal)
    #left as exercise for the reader
    #read file into a variable using system.file.readFileAsBytes()
    contents = system.file.readFileAsBytes(file_path)
    #return the file contents
    response = { 'bytes': contents, 'contentType': 'application/pdf' }
    
    return response

```

[Previous page](https://forum.inductiveautomation.com/t/pdf-viewer-dynamic/94056.md?page=1)
