import pdf file

  • Is there any way to import PDF file data in to a database table?

     

    Kavita

  • You can store the .pdf file in an image field.

    I don't see how you could import the contents of the .pdf file though.

  • I don't have experience of all the latest tools for PDF manipulation (and this area has grown a lot in the last 5 years), but I have worked inside PDFs. Strongly suggest that if you need data from within the file rather than storing the file itself, you go back to the originator of the data and talk about having it provided in a different format.

    If you can't get any other format, depending on the volumes, it may be better to get someone to copy and paste the data. I know this may seem like heresy, but your customer should think hard about whether automation makes sense.

    Bill.

     

    Sometimes the best solution is a pencil and paper.

  • If you are looking to import the data I would investigate the possibility of using xml. There are plenty of freebie pdf ocnverters out there that convert to all types of format, including xml. See this one: http://www.pdf2text.com/convert-pdf-to-xml-com-component.htm

    Once you have xml, you can see if the conversion produces consistently formated output and use dts to import it in. Or, you may be able to xsl templates to reformat after conversion to xml.

    This will not be a five minute job so you will have to weigh up the investment in time and development to the benefit you will gain by importing the data into a table.


    ------------------------------
    The Users are always right - when I'm not wrong!

  • I got this from an earlier thread and was importing pdf data quickly.  Button1 is on my VS Form to run the procedure.  MyImages is the name of the table you are using.  Added the code snipit referenced to my VS project and adjusted for my server.  You need the connection string defined also, otherwise this is complete.

    Let me know how you are causing a PDF to be displayed back to the user.

    Dim da As New SqlDataAdapter("Select * From MyImages", con)

    Dim fileLocation As String = "Insert_your_Location_and_name_of_PDF"

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)

    Dim ds As New DataSet

    da.MissingSchemaAction = MissingSchemaAction.AddWithKey

    Dim fs As New FileStream(fileLocation, FileMode.OpenOrCreate, FileAccess.Read)

    Dim MyData(fs.Length) As Byte

    fs.Read(MyData, 0, fs.Length)

    fs.Close()

    con.Open()

    da.Fill(ds, "MyImages")

    Dim myRow As DataRow

    myRow = ds.Tables("MyImages").NewRow()

    myRow("Description") = "This would be description text"

    myRow("imgField") = MyData

    ds.Tables("MyImages").Rows.Add(myRow)

    da.Update(ds, "MyImages")

    fs =

    Nothing

    MyCB =

    Nothing

    ds =

    Nothing

    da =

    Nothing

    con.Close()

    con =

    Nothing

    MsgBox("Image saved to database")

    End Sub

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply