PDF in HTMLViewer

I want to show a PDF file on disk in a HTMLViewer:

[code] Dim f As FolderItem = GetFolderItem(“Mac HD:Users:sander:Desktop:1.pdf”)
If f <> Nil And f.Exists Then
App.MyFile = WebFile.Open(f)

HTMLViewer1.URL = App.myFile.URL

End If
[/code]

Doesn’t work. It downloads the PDF but that’s not what I want. Anybody?

you need to specify the path format for the GetFolderitem call…
and webfile may need right mime type.

Yes! The mime type did the trick:

App.myFile.MIMEType = “application/pdf”

Thanks!

Hi! I need help, I have the same problem whit my webApp, but my pdf is in temp files directory, I can’t show it in a in a HTMLViewer

    dim wfile As new WebFile
    dim itemFolder As FolderItem
    itemFolder = SpecialFolder.Temporary.Child("MyPdf" + V + ".pdf")
    //TextArea1.Text = itemFolder.URLPath
    
    If itemFolder <> Nil And itemFolder.Exists Then
      TextArea1.Text = "..."
      wfile = WebFile.Open(itemFolder)
      wfile.MIMEType = "application/pdf"
      HTMLViewer1.URL = wfile.URL
    else
      TextArea1.Text = "Something is wrong :("
    end

Can help me please?

[quote=158204:@Esteban Ramirez]Hi! I need help, I have the same problem whit my webApp, but my pdf is in temp files directory, I can’t show it in a in a HTMLViewer

[/quote]

So what happens exactly ? Your code does not find the file, or it does not display ? If your client is on PC, the PDF will not display in Internet Explorer without an Adobe Reader plugin.

Your WebFile is going out of scope. I think that kills it before it gets a chance to display. Try using a property of the webpage instead of dimming it locally.

Thanks for the reply, I’m using mozilla firefox and I think that it does not find the file:
404: File Not Found

The requested URL “/5B2EB0C71276EB725BBC1D95562A7E17/files/%7B8091-8737-0408-6300-6098%7D/MyPdfvisita%3Dert.pdf” could not be found. Please check your request and try again.

Sorry I’m new in xojo. Can you help me with and example of how use a property of the webpage instead of dimming it locally?
thanks!

[quote=158399:@Esteban Ramirez]Thanks for the reply, I’m using mozilla firefox and I think that it does not find the file:
404: File Not Found

The requested URL “/5B2EB0C71276EB725BBC1D95562A7E17/files/%7B8091-8737-0408-6300-6098%7D/MyPdfvisita%3Dert.pdf” could not be found. Please check your request and try again.[/quote]

Tim tried to explain to you that when the event in which you dim wfile ends, wfile ceases to exist. Anything you dim in an event has a scope limited to that event.

So the HTMLViewer cannot use a variable that does not exist anymore.

  • Add a property called wfile of type WebFile to the WebPage (right click)
  • Modify the first line of your code as :
wfile = new WebFile

A WebPage property has a scope of that webpage. It is available to all controls in that webpage, and is available as long as the webpage exists.

[quote=158412:@Michel Bujardet]Tim tried to explain to you that when the event in which you dim wfile ends, wfile ceases to exist. Anything you dim in an event has a scope limited to that event.

So the HTMLViewer cannot use a variable that does not exist anymore.

  • Add a property called wfile of type WebFile to the WebPage (right click)
  • Modify the first line of your code as :
wfile = new WebFile

A WebPage property has a scope of that webpage. It is available to all controls in that webpage, and is available as long as the webpage exists.[/quote]

Thanks for the help, declare as a “WebPage property” solved my problem!