I am going to try to explain this the best I can
I didn't develop the original version of this, or the part that rights it to the database.

in our company, there is a program that takes PDF files and stores them in our mysql database as blobs. The blobs are attached to inventory items by the inventory items ID. they are basically certificates. That is basically all I know about it.

however, I was asked to show the PDF files for certain associates that may want to view them. ie, if a sales person looks up item 1234 and there is a stored PDF certificate for the item, be able to access the pdf and show it to the employee if they want to see it.


The code that I found that was previously wrote to view the PDFs takes the blog, create the file in the app.path directory, and then uses shell to launch it like a normal PDF.

I don't have a problem using the adobe pdf reader to launch the file, but is there a more efficient way other than creating the file on any machine in our company where someone wants to view the PDF ?


hopefully that is clear, here is the code that reads the blob currently:

Dim adoconnect As New ADODB.Connection
Dim adors As New ADODB.Recordset
Dim found As Boolean
adoconnect.Open "DSN=" & clssystem.DSN, clssystem.System_User, clssystem.System_Password

found = False
adors.Open "Select * from inventory_certs where stock_number = '" & Me.Stock_Number & "' ", adoconnect
If adors.EOF = False Then
    LoadImage adors, adors.Fields("file_name")
    found = True
End If

adors.Close


Set adors = Nothing
Set adoconnect = Nothing






Private Function LoadImage(ByRef rs As ADODB.Recordset, FileName As String) As Boolean
    Dim st As New ADODB.Stream
    Dim strTemp As String
    strTemp = App.Path & "\"
    st.Type = adTypeBinary
    
    strTemp = strTemp & FileName
    st.Open
    st.Write rs.Fields("data").Value
    st.SaveToFile strTemp, adSaveCreateOverWrite
    'Shell "open " & strTemp
    Shell "Cmd /c """ & strTemp & """", vbHide
    'Kill (strTemp)
    st.Close
    Set st = Nothing
End Function

* note, this code is in VB6 I haven't upgraded it to .NET yet because I don't want to upgrade a code that I don't like.


Thanks.

Are you doing this through a web application or windows application?

For a web application, you could try using a webbrowser control, add it to your form and then use the Navigate method to display it in the browser control...

myWebbrowser.navigate("d:\test.pdf")

Or maybe i've misunderstood the original question lol

- Jordan

its a desktop application,

the easiest i can explain

1) guy scans certificates into the database (blobs). the scanned certs are originally PDF.
2) i have an inventroy lookup system that they asked to have show the stores CERTS.
3) the code i got retreives the blob from the database, writes a new file to the local computer (whatever.pdf) from the database data, then uses the shell launcher to launch the application. (processes.start in .net)

i would like to accomplish steps 2 and 3 without having to recreate the file on the local machine each time someone looks up a certificate...

hopefully that clears it up

i think that either way i am going to have to store the file to the local disk.. it kind of confuses me but i guess i will just stick with the current method

I guess I am looking for a class that can accept the decompile PDF data, turn it into a compiled PDF and show the end results without having to save the file to the local disk.


thanks.

This article has been dead for over six months. Start a new discussion instead.