Skip to content
HTKapp
Browse the documentation

Table extraction module (CSV)

The Extract Table module converts the tabular data detected in a PDF into a CSV (Comma-Separated Values) file. This simple text format is compatible with Microsoft Excel, Apple Numbers, Google Sheets, LibreOffice Calc and almost every data-processing tool. It is an export operation: the open PDF document is not modified. You reach this module from the Conversion category of the Dashboard.

Step 1 — Selecting the pages containing tables

Table extraction works page by page. Before opening the module, or directly in the preview grid on the left, select the pages that contain the tabular data to extract:

  • Without a selection: HtkPDF goes through the whole document. The sidebar then reads "All pages";
  • With a selection: only the ticked pages are analysed. The summary states the number of pages selected.

Restricting the analysis to specific pages is strongly recommended, for two reasons:

  1. Performance: the analysis goes through each page to spot tabular areas. On a long document, that can take time;
  2. Accuracy: limiting the scope reduces the risk of false positives (paragraphs wrongly interpreted as table rows).

Step 2 — Running the extraction

The sidebar contains no further parameters: the extraction uses HtkPDF's automatic detection algorithm, which spots areas structured into aligned columns (text or numbers separated by spaces or separator lines).

Click Extract (CSV). An "Export operation" dialog reminds you that:

This action will export the extracted tables directly into the folder of your choice. The current document will stay open and unchanged.

Confirm with I understand to open a macOS save panel. The folder proposed by default is the one set in Settings > Files, and the file name proposed is <original_name>_tables.csv.

While extracting, the button reads "Extracting…" and stays disabled.

Format of the generated file

The file produced is a standard CSV:

  • UTF-8 encoding — preserves accents and special characters;
  • Separator: comma;
  • One line per table row;
  • One cell per column, without quotes unless the cell itself contains a comma.

If several tables are detected (on different pages or in several areas of the same page), they are concatenated into the same file, separated by a blank line. You can split them apart manually after opening the file in your spreadsheet.

Opening the file in a spreadsheet

  • Apple Numbers: double-click the file — Numbers recognizes the format and offers a clean import;
  • Microsoft Excel: when opening, choose the Delimited option with Comma as the separator. If accents display badly, select UTF-8 encoding in the import dialog;
  • Google Sheets: use File > Import, choose the CSV and the comma separator.

Limits and best practices

Extracting tables from a PDF is a heuristic operation: a PDF does not, by nature, contain a formal table structure. HtkPDF relies on the geometric alignment of the cells to reconstruct the grid. That implies a few limitations:

  • Tables with complex rows: tables whose cells span several lines or contain internal line breaks may have their structure broken up;
  • Merged tables: cells merged in the original PDF are not restored as such. A cell merged across two columns may appear either duplicated or in the first column only, depending on the layout;
  • Scanned PDFs: on a scanned document without a text layer, no extraction is possible. Run a Text extraction with OCR first, then copy and paste the results into a spreadsheet.
  • Badly aligned tables: if the columns of the original PDF are not precisely aligned (centerd text, floating margins), the result may need manual touch-up in the spreadsheet.

Tip: for a long document, run the extraction first on a single page containing a representative table. Check the quality of the result in your spreadsheet, then run the extraction on all the useful pages. That avoids spending a lot of time on a final export you would have to touch up anyway.

Returning to the Dashboard

Once the extraction has finished successfully, the module closes automatically and the Dashboard becomes visible again. The original PDF document has undergone no change.

Screenshots

1 screenshot — click to enlarge