# PDF to WebHTMLViewer working on Mac but not windows

**URL:** <https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682>\
**Category:** Web\
**Created:** [May 17, 2017, 10:19pm UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682 "2017-05-17T22:19:09Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Baughman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/f17d59/32.png) [@John\_Baughman](https://forum.xojo.com/u/John_Baughman)\
**Post date:** [May 17, 2017, 10:19pm UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/1 "2017-05-17T22:19:09Z")

</div>

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/](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

---

<div class="post-metadata">

**Author:** ![Richard\_Duke](https://forum.xojo.com/user_avatar/forum.xojo.com/richard_duke/32/246_2.png) [@Richard\_Duke](https://forum.xojo.com/u/Richard_Duke)\
**Post date:** [May 17, 2017, 10:30pm UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/2 "2017-05-17T22:30:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![brian\_franco](https://forum.xojo.com/user_avatar/forum.xojo.com/brian_franco/32/156_2.png) [@brian\_franco](https://forum.xojo.com/u/brian_franco)\
**Post date:** [May 17, 2017, 10:36pm UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/3 "2017-05-17T22:36:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John\_Baughman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/f17d59/32.png) [@John\_Baughman](https://forum.xojo.com/u/John_Baughman)\
**Post date:** [May 18, 2017, 1:02am UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/4 "2017-05-18T01:02:01Z")

</div>

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/](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

---

<div class="post-metadata">

**Author:** ![John\_Baughman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/f17d59/32.png) [@John\_Baughman](https://forum.xojo.com/u/John_Baughman)\
**Post date:** [May 18, 2017, 1:30am UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/5 "2017-05-18T01:30:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [May 18, 2017, 7:20am UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/6 "2017-05-18T07:20:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John\_Baughman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/f17d59/32.png) [@John\_Baughman](https://forum.xojo.com/u/John_Baughman)\
**Post date:** [May 18, 2017, 10:55am UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/7 "2017-05-18T10:55:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Carsten\_Belling](https://forum.xojo.com/user_avatar/forum.xojo.com/carsten_belling/32/11665_2.png) [@Carsten\_Belling](https://forum.xojo.com/u/Carsten_Belling)\
**Post date:** [May 18, 2017, 12:15pm UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/8 "2017-05-18T12:15:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John\_Baughman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/f17d59/32.png) [@John\_Baughman](https://forum.xojo.com/u/John_Baughman)\
**Post date:** [May 19, 2017, 12:38am UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/9 "2017-05-19T00:38:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John\_Baughman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/f17d59/32.png) [@John\_Baughman](https://forum.xojo.com/u/John_Baughman)\
**Post date:** [May 21, 2017, 4:03am UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/10 "2017-05-21T04:03:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:46pm UTC](https://forum.xojo.com/t/pdf-to-webhtmlviewer-working-on-mac-but-not-windows/37682/11 "2020-10-29T18:46:18Z")

</div>


