# Perspective PDF Viewer Failed to load PDF file

**URL:** <https://forum.inductiveautomation.com/t/perspective-pdf-viewer-failed-to-load-pdf-file/69235>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [January 31, 2023, 8:27pm UTC](https://forum.inductiveautomation.com/t/perspective-pdf-viewer-failed-to-load-pdf-file/69235 "2023-01-31T20:27:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jlee](https://forum.inductiveautomation.com/u/jlee)\
**Post date:** [January 31, 2023, 8:27pm UTC](https://forum.inductiveautomation.com/t/perspective-pdf-viewer-failed-to-load-pdf-file/69235/1 "2023-01-31T20:27:06Z")

</div>

Hi, I'm currently having trouble with the PDF Viewer Perspective component. I am using 8.1.17 and the WebDev module version 5.1.17.

I'm just trying to do a simple test of loading a PDF onto the PDF viewer using the WebDev module. I have followed all the forum posts to do this, but still can't manage to load the PDF file.

Here is what I have:

1. DB table that holds the file BLOB:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/f/6ff60fbcb59d8d0d8b9227adbb7ebfd8fc602076.png)  
Note that the fileData column is varbinary (MAX).

2. Entries get inserted into the DB table from #1 with the fileData column coming from event.file.getBytes() from the File Upload component. (User uploads a pdf using the application and they need to be able to load that PDF later on within the same application.)

3. Named Query: IngotFile/getIngotFile  

4. Web Dev doGet: getIngotFile  
It runs the named query from #2 and returns the dictionary. I have tested that it does get the correct fileData (when I log it, I see the byteArray.)  

5. PDF Viewer source expression binding  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/9/19c2b71d173b9c2789a3d6d8ed08d6f688f7c1b3.png)  
The fileId=10 is hardcoded for testing purposes. projectName is the actual project name in my Designer. Just didn't want to reveal customer name.

When I do this, the PDF Viewer just says "Failed to load PDF file."  
Is there anything here that I'm blatantly missing?

I have also tried using the Vision PDF Viewer and that component also could not read the files that were saved from using the File Upload component.  
What is interesting is that it was able to read the pdf file bytes that were saved using the following in Vision.

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

These files, however, still do not load on the Perspective PDF Viewer component.

---

<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:** [January 31, 2023, 9:54pm UTC](https://forum.inductiveautomation.com/t/perspective-pdf-viewer-failed-to-load-pdf-file/69235/2 "2023-01-31T21:54:29Z")

</div>

> [@jlee](#):
>
> Vision PDF Viewer and that component also could not read the files that were saved from using the File Upload component

That suggests the file in the DB was corrupted on upload somehow. Try writing the blob back out to the filesystem and comparing to the original. Also, have you seen this?

> [@Automation Professionals' Blob Server Module](https://forum.inductiveautomation.com/t/automation-professionals-blob-server-module/57970):
>
> Automation Professionals is pleased to announce an alpha release of its new Blob Server Module. Available only for Ignition v8.1, here. The Blob Server Module provides a simple way to deliver images, PDF files, or other binary content from a database to your Perspective clients or other web applications. Without needing the WebDev module. All you need is a Named Query that has appropriate security settings and returns a single row with two columns: Content, and ContentType. Modest documentati…

---

<div class="post-metadata">

**Author:** ![jlee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jlee](https://forum.inductiveautomation.com/u/jlee)\
**Post date:** [February 1, 2023, 3:24pm UTC](https://forum.inductiveautomation.com/t/perspective-pdf-viewer-failed-to-load-pdf-file/69235/3 "2023-02-01T15:24:14Z")

</div>

Ah, it seems like the file was corrupted.

I tried it again with a new file, it worked on the Vision PDF viewer, but not on the Perspective PDF viewer.  
So I knew it was something with the way I configured the Perspective PDF Viewer approach.

Figured out that the parameter in line 4 in the doGet script should have been just request['params'], not {'fieldId': request['params']}, since request['params'] already has the structure of {'fieldId': fileId}

Thank you for the help!
