PDF to WebHTMLViewer working on Mac but not windows

Building and Debugging on a Mac everything works…

formURL = DocumentDict.Value("filePath") //filePath looks like this.. // on Mac: /Users/johnbdh2/programming/QMC/QMCDocs_Done/Box 048/QDC/1977PB1Signage_CD(048)/008_G8_A_1977PB1Signage_CD.pdf // on PC: C:/QMCDocs_Done/Box 048/QDC/1977PB1Signage_CD(048)/008_G8_A_1977PB1Signage_CD.pdf myPDFFile = WebFile.Open(PathToFolderItem(formURL)) myPDFFile.MIMEType = "application/pdf" htmlViewer_Document.URL = myPDFFile.URL

When I build and run it on Windows 2008 Server the htmlViewer does not change. The HTMLViewer has http://www.example.com/ set as the default page, and it does not change to the requested PDF on Windows.

Do I have to do anything different on Windows. I am guessing something is wrong with the POSIX format on the windows machine. I have verified that the path being passed is valid on the windows machine.



i think the slash for the pc is wrong. should be the other way.

I agree with RichardD

// on PC: C:/QMCDocs_Done/Box 048/QDC/1977PB1Signage_CD(048)/008_G8_A_1977PB1Signage_CD.pdf

should be:

// on PC: C:\QMCDocs_Done\Box 048\QDC/1977PB1Signage_CD(048)\008_G8_A_1977PB1Signage_CD.pdf

Ok I tried C:\QMCDocs_Done\… but it did not work either.

I changed xojo code to use a FolderItem set to use PathTypeNative…

[code]Dim f As FolderItem
f = New FolderItem(DocumentDict.Value(“filePath”),FolderItem.PathTypeNative)

IF f.exists Then
myPDFFile = WebFile.Open(f)
myPDFFile.MIMEType = “application/pdf”
htmlViewer_Document.URL = myPDFFile.URL

MsgBox “File does not exist”

end if[/code]

On the Mac this works fine.

On the PC I do not get any errors nor do I get the MsgBox alert which must mean that the FolderItem f is valid. I just do not get the PDF. The HTMLViewer just continues to show the default http://www.example.com/.

On the Mac I am passing in DocumentDict.Value(“filePath”), per the Xojo docs, the POSIX path, ie. /Users/johnbdh2/programming. On the PC I am passing C:\QMCDocs_Done\Box 048\… but the docs do not specify what the path should look like.

Any ideas?


Sorry. Just figured out that on the PC the code to display the PDF was not even being called.

Hopefully this little exercise/post will help someone else in the future.

Thanks for replying.


Note that on PC, only Edge and Chrome will display PDF natively. Internet Explorer will require the Adobe Reader plugin.

I am back. The code is getting called and I am now getting an error (pasted below).
So I revised the code to check the file path…

Dim f As FolderItem
f = New FolderItem(DocumentDict.Value(“filePath”),FolderItem.PathTypeNative)
If f.Exists Then
msgBox f.NativePath
myPDFFile = WebFile.Open(f)
myPDFFile.MIMEType = “application/pdf”
htmlViewer_Document.URL = myPDFFile.URL

msgBox “file does not exist”+EndOfLine + EndOfLine + f.NativePath

end if
myPDFFile is a previously declared WebFile. Again this works fine on the Mac but not the PC where it drops into “file does not exist”. On the Mac the file path is in POSIX format /Users/johnbdh2/programming/… and on the PC it is C:\QMCDocs_Done\Box 048\… I am absolutely certain that the file does indeed exist.

The problem is not the browser as the problem occurs before the pdf ever gets to the HTMLViewer.


Unhandled NilObjectException



Maybe you have to use the prefix “file://”. In this case I think you have replace the backslashes of the path with slashes.

Ok, I am giving up. I have changed it to an http request to the database server rather than loading the file directly…

htmlViewer_Document.URL = “http://”+HostDatabaseIP+"/"+DocumentDict…Value(“filePath”)

This actually works better for me as the documents must now stay with the host database and not with the xojo web app. Since the host database keeps track of the file locations, this makes much more sense. I don’t really see any difference in speed to retrieve the pdfs via http or directly off the web app’s hard drive.


Just wanted to clarify that this was in fact a problem with my XMLReader. It was leaving line feed at the end of the filePath and so the error. Fixed my XMLReader and the windows web app is now working fine.

Thanks for the help.