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.

Thanks,

John

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

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

John

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.

John

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

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

John

Unhandled NilObjectException
Message:

Stack:

cnt_Explore.cnt_Explore.LoadDocument%%o<cnt_Explore.cnt_Explore>o
cnt_Explore.cnt_Explore.lb_Documents_SelectionChanged%%o<cnt_Explore.cnt_Explore>o
Delegate.IM_Invoke%%o
AddHandler.Stub.31%%
WebListBox._ExecuteEvent%b%osA1v
WebControl.!_ExecuteEvent%b%ssA1v
WebSession._HandleEvent%%oso<_HTTPServer.HTTPRequestContext>
WebSession._HandleRequest%i4%oso<_HTTPServer.HTTPRequestContext>
WebApplication._HandleHTTPRequest%%oo<_HTTPServer.HTTPRequestContext>
_HTTPServer.HTTPRequestThread.Event_Run%%o<_HTTPServer.HTTPRequestThread>

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.

John

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.

John