1

I have many account balance documents, I need to create an Excel file from a table inside these documents. I can proceed with a normal OCR recognition but the main problem is that these PDFs have page headers, page footers table headers and so on, I would like to parse only a selected area of the page (with x,y coordinates) for every pages.

Is it possibile to do this?

  • It's always possible to use Imagemagick after to extract only a subimage. So scan-->extract subimage--> Ocr on the subimage --> txt data. – Hastur Dec 14 '15 at 9:23
  • So your suggestion is to extract a croped image on the table only and then ocr it? – Tobia Dec 14 '15 at 9:24
  • If you have the pdf version it's better and you can think different too: it's probably possible to extract the data directly. If you can set you scanner or your ocr too (usually it depends from the ocr, but it is possible to define the area to "ocr"). If not you can always get rid of all this and extract the sub image, then ask to ocr to do the "whole" sub-image. :) – Hastur Dec 14 '15 at 9:26
  • At the end I croped the document to fit the interested area. I exported it to one image per page and then I merged and parsed them! – Tobia Dec 15 '15 at 6:54
  • Probably one of the most quick way. A more long answer below. – Hastur Dec 15 '15 at 8:57
0

PDFs files can be very different one from another and contain links, buttons, form fields, audio, video, business logic, or they can be a simple collection of scanned images one for page even if they are a standard. Indeed the Portable Document Format, shortly PDF, are an open standard maintained by the International Organization for Standardization (ISO) [1].

The strategy to extract data from a PDF can differ accordingly with its content, and not always the best way is to use an OCR; if the data is available directly inside it's better to avoid a level of data treatment that is not completely error free.

  • If PDFs are created from a word processor document (Word,Latex...) you have good possibilities to successfully extract data without the need to recur to any OCR software. With some viewer you can select the table and export/save the selection at least in txt format or in the csv one; then you can import it in eXcel. A fast search on your preferred search engine will give you an updated list of "open source" or "freeware" pdf tools export, or you can give a look to the wikipedia page about pdf software [1b].
  • There are some tools, even open source or freeware, created for this purpose and available for each operative system. With the Adobe program you can select the table and export directly [2] in xls or xlsx... Again a fast search on your preferred search engine will give you an updated list of "open source" or "freeware" pdf viewers export table.

  • There are some internet site that offer for free this service, even if for bills I should not suggest you... included the google docs one [3].

  • Last but not least if they are images or the other strategies failed you can use the OCR, setting a box to limit the OCR options. With FreeOCR [4],for example, you can select the a box on which perform the OCR...

    You can draw a box around part of the image using your mouse and then OCR the current page. This is handy if you just want to get the text from one region of the page.

  • If your OCR didn't support that feature, or it is not cosy to process many file at the same time, you can always recur to Imagemagick [5] or any other tool and extract a sub-image of the interesting area. Then you can give to your OCR only the selected sub-image, without header or useless area.
    So scan-->extract subimage--> Ocr on the subimage --> txt or csv data-->eXcel.

    With Imagemagick convert you can do something similar to

    convert -size 2480X3508 -depth 8 -extract 640x480+1280+960 file.pdf img.png
    

    to convert a PDF file to a PNG one, with the A4 page size dimensions for 300 DPI and extract a box with the geometry parameters [6] of 640x480 starting from the point 1280+960.
    Note that if manual scanned you will see different position of your region of interest for each page.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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