logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Paul Rayman  
#1 Posted : Tuesday, January 5, 2016 3:54:30 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Question:
Is there a way to automate tabular data extraction from a number of pdf files?
Regularly I have to go through a list of pdf files and search for specific data and add them to an excel sheet for later review.
The pdf files I work with are tabular and have similar structures.

Answer:

The problem is that PDF in general is not a structured file format. It doesn't have information about columns, paragraphs, tables, sentences or even words. Basically it cares only about characters on a page in specific locations.
This means that generally you cannot query a PDF document and extract text for every cell in a table. But you can ask a library to get all of the text in a specific location.
So, if you can determine coordinates of the cells in a document and they are same from file to file, then you can extract the text using the following technique:

Code:

public void ExtractTabularText()
{
    //Initialize the SDK library
    //You have to call this function before you can call any PDF processing functions.
    PdfCommon.Initialize();

    //Open and load a PDF document from a file.
    using (var doc = PdfDocument.Load(@"c:\test001.pdf"))
    {
        foreach (var page in doc.Pages)
        {
            //Specify the cell coordinate in page coordinate system
            var rect = new FS_RECTF() { left = 45.0f, right = 55.0f, top = 245.0f, bottom = 137.0f };
            //Extract text within a rectangular boundary on the page specified by a FS_RECTF structure
            string cellText = page.Text.GetBoundedText(rect);
        }
    }

    //Release all resources allocated by the SDK library
    PdfCommon.Release();
}
Users browsing this topic
Guest (3)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.