Perspective PDF Viewer Failed to load PDF file

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
    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
    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

These files, however, still do not load on the Perspective PDF Viewer 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?

1 Like

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!