Sub WebView1_OverrideUrl (Url As String) As Boolean
If Url.EndsWith(".docx") Then
DownloadFile(Url,"ficheiro.docx")
Return True
Else If Url.EndsWith(".pdf") Then
DownloadFile(Url,"ficheiro.pdf")
Return True
Else
Return False
End If
End Sub
Sub DownloadFile (link As String, FileName As String)
Dim j As HttpJob
j.Initialize("", Me)
j.Download(link)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim out As OutputStream = File.OpenOutput(File.DirDocuments,FileName, False)
File.Copy2(j.GetInputStream, out)
out.Close
di.Initialize("di", File.DirDocuments, FileName)
di.PreviewFile(Page1)
Else
Msgbox(j.ErrorMessage, "Erro")
End If
j.Release
End Sub