File Access on host from remote client

I am looking to have the ability to view pdf files that reside on the host client from any of the remote clients. Specifically I have a pdf viewer with a file explorer on the same window to select which pdf file to view.

I attempted to use:


any ideas?


Getting windows network file paths right can be tricky, maybe try:




or share the reports folder on the server to get rid of the C$ part


Thanks for the suggestions. It looks like: \\Reports\report01.pdf works. I did have to share the directory.

Thanks again,


OK Carl, Issue back open.

It looks like for this to function, in other words for me to be able to access the shared directory, I need to login to the pc. This is why it was working for me the other day.

Is there a way to “Force” the directory viewer to the local (on the host) specific directory?

Can I do something like: “file://LocalHost/C:/Reports/”
OR does that not make sense?

thanks again,

No, that doesn’t make sense. In order to use windows filesharing, you’ll have convince windows that you have permissions to the file. So either you configure the share on the host computer to let anyone read from it, or you log in first.

The other option is to use something other than windows filesharing. Conveniently, you already have a web server (FactoryPMI Gateway) installed. If you drop files under the C:\Program Files\Inductive Automation\FactoryPMI\tomcat\webapps\ROOT directory, they will be served up over http, and you can access them like this:

You have a number of options:

  1. Store it on the FactoryPMI Gateway (Web server) as Carl suggested.
  2. Store it in a BLOB in the SQL Database.
  3. Try mapping the network share as a lettered “drive”. You would use the
    fpmi.system.execute() function to run the command.

The DOS command is: “net use”, “net use /help” will give you the optional paramaters. It includes options for a username and password.

For example: "net use s: \\Reports\ password /USER:myusername

I spoke with Adam earlier today on the phone. He is going to store the PDFs as BLOBs in the database - much more user friendly to skip the hassle of dealing with windows filesharing.

Yes, After speaking with Carl yesterday, we decided to save my report as a PDF into the db as BLOB.

We worked on the scripting to get the data from the db and put dynamically into a PDF viewer component. I, however, think my script to save the report into the db is not working. Below are my scripts.

This is the code to save the report in the db. I have a BLOB type column in the table called “printedreports”:

report = event.source.parent.getComponent('Report Viewer') fileName = "ReportName" filedata = report.getBytesPDF() fpmi.db.runPrepStmt("UPDATE printedreports SET pdfBytes = (?) WHERE filename = (?)", [filedata, fileName])

This is the code to retrieve the BLOB data:

filename = "2008-07-23 0500" bytes = fpmi.db.runQuery("SELECT pdfBytes FROM printedreports WHERE filename='%s'"%filename) tempfile = fpmi.file.getTempFile("pdf") # Create Temp PDF File place holder fpmi.file.writeFile(tempfile, bytes) #Generate Temporary PDF File event.source.parent.getComponent("PDF Viewer").filename = 'tempfile'

when I run either script, I do not get errors. When I run the retrieval script, I do not see the pdf file. Also, when I view the temp file, I do not see anything. It is only 1k rather than the 4k size that the actual pdf’s are.

Any ideas?

Try these modifications to your scripts:

report = event.source.parent.getComponent('Report Viewer') fileName = "ReportName" fileData = report.getBytesPDF() fpmi.db.runPrepStmt("UPDATE printedreports SET pdfBytes = ? WHERE filename = ?", [fileData, fileName])


filename = "2008-07-23 0500" bytes = fpmi.db.runQuery("SELECT pdfBytes FROM printedreports WHERE filename='%s'"%filename) if len(bytes)>0: tempfile = fpmi.file.getTempFile("pdf") # Create Temp PDF File place holder fpmi.file.writeFile(tempfile, bytes[0][0]) #Generate Temporary PDF File event.source.parent.getComponent("PDF Viewer").filename = tempfile else: fpmi.gui.warningBox("No report for filename '%s'" % filename)

Hope this helps,


Yes it worked. It looks like that did the trick. I guess between grabbing as a byte array as well as my extra parenthesis around the “?” did the trick.

Thanks again,


The main problem was writing the variable bytes to the temp file. [color=GRAY](yes - thats what I told you to do on the phone yesterday - my bad)[/color]

bytes is a PyDataSet - the return of a query. using bytes[0][0] gets the value from the first row, first column, which is the BLOB data.

One minor problem I now have is that inthe code where we make sure data is there before creating the temp file:

if len(bytes)>0:

The return of this is always 1 as this is the length of the array.

Is there a way to get the actual number of bytes of the data? This way we can differentiate between a return with NULL (not saved to) and actual PDF data that has been saved.

Thanks for your patience with my lack of knowledge on this.


As a quick fix, I added into my loading of the dataset: WHERE pdfBytes is not NULL which works for me for now…

Yep, the WHERE clause is a good way of doing it. The len(bytes) check is to make sure the database returned at least 1 row.

I would be VERY interested in using something like this. Anyway I can get a copy of the window or HOW TO??

I follow the code, but unsure about certain elements within it…


fileData = report.getBytesPDF()

That line simply retrieves the currently displayed chart as the bytes of a PDF. You could write these bytes to a *.pdf file, or email the bytes to someone as a *.pdf, or store them in the database for later retrieval.

Iam trying to access pdf file stored at the Gateway Server (Ignition) from the clients. I dont want to stored then in a DB. What else can I do?

You can create a shared folder on the gateway to access the PDFs from.

Ok I placed the file here and can pull it up from any computer on the network…

But it will not show up in the PDF viewer in my project…

What error or you getting? Are you using the PDF viewer component under reporting or the ActiveX adobe reader?

Im using ICEpdf-Viewer.
It also works fine if I use this Add but only on the localhost not on the network for clients. Half my clients running Ubuntu so no Acitvx.
C:\Program Files\Inductive Automation\Ignition\tomcat\webapps\main/dar.pdf

Componet name"http://IPADD:8088/main/dar.pdf" is invalid, it is either non-unique,reserved, or has an illegal charactr.