PDF Viewer Caching

I have PDF of product specs on a local webserver. I use PDF to access exemple.com/pdf/somespec.pdf

And that works fine… my problem is when we change the specs, I upload the PDF to the server. If I look with a browser the pdf is updated… but in Ignition, my old pdf is still showing, even if I open or close the projet… seem that it gets cached somewhere…

I don’t want it to cache… Any idea?

What component are you using to view the pdf?

PDF Viewer

Sorry for not making it clear – there are two different Ignition components commonly called PDF Viewer. If you have the Reporting module, one of the Vision components it provides is called ‘PDF Viewer’, and there’s also an IALabs module called ‘PDF Viewer’.

Report module

Good to know. Looking at the source code, it seems the only way for you to force a reload is to change the filename. Setting it to “” and immediately setting it back to what you want would force the reload.

Do you have an example on how to script that… I tried to change the file name to “” then to file… still shows the cashed…

Hmmm… I can’t replicate any caching problems. (Using Ignition as the web server.)

Script I used is this: viewer = event.source.parent.getComponent('PDF Viewer') viewer.setFilename("") viewer.setFilename("http://localhost:8088/main/test.pdf")

I put that on a button, in between button presses I replaced the pdf at that location. Each button press brought up the current (not cached) version of the pdf. :scratch:

I tried to use the Ignition server as webserver for the PDF, same results. Well in my case I can’t run the client on the server itself, nor the designer. So I put the IP of the server instead of localhost. Same difference

My Ignition 7.7 server is a Linux (Ubuntu 14.04) server , I tried the client on both Linux and Windows Client.

I even tried a different button for the viewer.setFilename("") and the viewer.setFilename("")

Still does the same thing

If I close the client completely and open it up again, the first asdf.pdf that it will load will be the new cashed. So for now each time we change the specs, we have to close the client on that machine and restart it… which can be a half fix work around…

But else that, would there be another way I could do this… basically it’s and open and close a pdf stored on a html server from a script… some sort of applet…

I’ve d/l the PDF Viewer Module form marketplace… Unfortunately it only do file path, and not URLPath :cry:

Just brainstorming here…

Is there a way I could download to a temp location and read PDF Viewer Module (Not the report one), but without having to hardcore the temp location. I have Linux and Windows clients… and hard coding temp location is a pain… A magical temp folder variable that would work with anyone

This generate a newly file with random name and specific extension in a temporary location, creating a new file, every time you call this function.

This other point to the “user” folder (which varies depending the OS), but it’s a mechanism to search or save a file in a local file system, in a os abstract way.

Hope this helps.

Thanks guys for your help!! Well here is how I got it working like I wanted.

import urllib

#url where the pdf is located on internal web server
url = 'http://qualite.gsi/pdf/palette/asdf.pdf'

#path is the string ot the temp.pdf file to be created, OS independent
homeDir = system.util.getProperty("user.home")
sep = system.util.getProperty("file.separator")
path = "%s%stemp.pdf" %(homeDir, sep)

#retrieves the pdf file and saves it as the temp.pdf in home directory
urllib.urlretrieve (url, path)

#Opens the windows pdf that has the PDF Viewer, the PDF Viewer component has the value of the parameter File as its file path.
system.nav.openWindow('pdf', {'File' : path})

Still can’t believe I took me 2 days in finding this :confused:

1 Like