0

I am trying to write either a standalone Windows Forms application or a VSTO Excel Add-in using C# or VB .net that can read a PDF file and pull data from it. The files I get are lists of traffic accident records created from a state database, and each crash record includes environmental data, accident particulars, and information about the involved parties.

In the PDF listings I receive, all of the data for a single crash is surrounded by a box, so to get the data, I envision first detecting the square surrounding the record, and then from the top left or top right coordinates of that square, most of the various data are always in the same relative locations. But the squares are not always the same size because there could be multiple parties involved, each of which gets listed at the bottom of each record. I would direct the parser to look for the next crash record when it reached the y coordinate of the bottom of the box. There could be other strategies for pulling the data, but this method seems like the easiest to code for now. The information is already searchable text, so I don't need OCR to digitize the data. I just need to put it in an Excel spreadsheet or some other type of file that can be read by Excel for my calculations. I don't need an API so long as it will integrate with Visual Studio.

This is purely to assist me in my own work and I do not intend to sell what I produce using the SDK, so royalties are not an issue. I am not a software developer by profession, but I learned C# and VB .net so I could automate repetitive or iterative calculations and perform other mundane engineering-related tasks. I don't need to create PDFs and I don't need to edit them, I just need to read the data. Since I don't intend to make any money directly from this project, I can't justify paying for an annual license or a huge one-time fee for an SDK that I will use only for parsing these PDF files. I don't expect to get it for free, and am willing to pay for it, if its cost is reasonable for my limited use.

My ballpark budget is under $250. It's worth that much to me to not have to parse accident histories by hand. I will entertain higher costs, but not much higher.

Any suggestions?

2
  • Could you provide a ballpark range for your budget? Commented Apr 20, 2023 at 18:06
  • I just added my price range to the post. Commented Apr 20, 2023 at 23:12

2 Answers 2

0

You can try Syncfusion PDF Library

This high-performance and feature-rich .NET PDF framework works without Adobe dependencies. It has a PDF creation and editing library that allows you to create, read, and edit PDF files programmatically in any .NET application. It offers PDF viewer controls to view, review, and print PDF files. Its powerful conversion APIs make it easy to convert HTML, Word, Excel, PowerPoint, and images to PDF.

https://www.syncfusion.com/document-processing/pdf-framework/net

Syncfusion offers a free community license also. https://www.syncfusion.com/products/communitylicense

Note: I work for Syncfusion

0

Since you mention Excel I suppose you have Office also, or at least WORD, in that case you can use the pdf functions of word and use them inside your .net code. Here is an example using VBA to get pdf data into excel, no external programs (except from office itself). this is to get the data from TABLES not from boxes (I think those would need to use SHAPES instead of tables or possibly .Pages(1).Rectangles.Item(n).Range).

Sub read_pdf_document_tables()

Const PDFPath As String = "C:\Users\xxxxxx\Documents\Book2.pdf"

Dim sht As Worksheet
Dim WDoc As Word.Document
Dim WApp As Word.Application
Dim i As Long, r As Long, c As Long
Dim rng As Range, t As Word.Table

    Set WApp = CreateObject("Word.Application")
    WApp.Visible = True
    Set WDoc = WApp.Documents.Open(PDFPath, ConfirmConversions:=False, ReadOnly:=False)

    Set sht = Sheets("Temp")
    Set rng = sht.Range("A1")
    sht.Activate

    For Each t In WDoc.Tables
        t.Range.Copy
        rng.Select
        rng.Parent.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:=False
        With rng.Resize(t.Rows.Count, t.Columns.Count)
            .Cells.UnMerge
            Cells.Columns.AutoFit
            Cells.Rows.AutoFit
        End With

        Set rng = rng.Offset(t.Rows.Count + 2, 0)
    Next t
    WDoc.Close
    WApp.Quit
End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.