Blob to HtmlViewer

I make a small app. In a SQLite Database I store pdf content on BLOB field (FileData) on a table call File.

I use this code found on the forum : here

[code]Var rs As RecordSet
Var dat() As String

rs = mDB.SQLSelect(“SELECT FileData FROM File”)

if rs<>Nil Then
dat.Append("")
dat.Append("")
dat.Append("")
dat.Append("<meta charset="“UTF-8"”>")
dat.Append("")
dat.Append("")
dat.Append("<object data="“data:application/pdf;base64,”)
dat.Append(EncodeBase64(rs.Field(“FileData”).NativeValue,0))
dat.Append(""" type="“application/pdf”" width="“100%”" height="""+Str(HTMLViewer1.Height)+“px”">")
dat.Append("")
dat.Append("")
dat.Append("")

HTMLViewer1.LoadPage( String.FromArray(dat,EndOfLine))
end if[/code]

Unfortunately HTMLViewer1.LoadPage need a FolderItem.

Is there a way to fill an HTMLViewer with string or I had to make a temp file ?

Thanks for your help…

For know this is my solution :

[code]If DBFileList.SelectedRowIndex < 0 Then Return

// Get the file to save the BLOB to
Var outputFile As FolderItem = SpecialFolder.Resource(“temp.pdf”)

If outputFile Is Nil Then Return

// ID is the Unique iddentifier on my Tabale
Var id As Integer = DBFileList.RowTagAt(DBFileList.SelectedRowIndex)

// Get the BLOB from the DB into a string
Var blob As SQLiteBlob = mDB.OpenBlob(“File”, “FileData”, id, False)

If blob <> Nil Then
Var output As BinaryStream
output = BinaryStream.Create(outputFile, True)

While Not blob.EndOfFile
Try
output.Write(blob.Read(1000))
Catch err as IOException
MessageDialog.Show(“Error reading from BLOB.”)
Exit While
End Try
Wend
blob.Close
output.Close

// Load file on HTML Viewer
HTMLViewer1.LoadPage(outputFile)
Else
MessageDialog.Show(“This BLOB column has no data.”)

End If
[/code]

Don’t do that. You can easily load a string into a htmlviewer:

HTMLViewer.LoadPage(Source As String, RelativeTo As FolderItem)

thanks @Beatrix Willius but what’s the value of RelativeTo ,

Use “Nil”.