npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pdf-tables-parser

v1.0.6

Published

Library to extract text tables from pdf files.

Readme

pdf-tables-parser

npm version

pdf-tables-parser is a JavaScript/TypeScript library designed to extract text tables from PDF files efficiently. It provides tools to parse PDF documents and extract structured table data with minimal effort, enabling you to handle tabular data in PDF files seamlessly.

Features

  • Extract tables from PDF files with ease.
  • Support for multi-page PDFs.
  • Handles text with overlapping and complex layouts.
  • Configurable options to tailor table extraction.
  • Lightweight and easy to integrate.

Installation

Install the library using npm:

npm install pdf-tables-parser
# or
pnpm add pdf-tables-parser

Usage

Here’s a basic example of how to use the library:

import { PdfDocument } from 'pdf-tables-parser';
import fs from 'fs';

(async () => {
    const pdfBuffer = fs.readFileSync('example.pdf');
    const pdfDoc = new PdfDocument({
        hasTitles: true,  // Indicates if tables have titles
        threshold: 1.5,  // Adjusts the y-axis grouping sensitivity
        maxStrLength: 30, // Maximum string length for a cell
        ignoreTexts: ['Example Ignored Text'] // Texts to ignore during extraction
    });

    await pdfDoc.load(pdfBuffer);

    pdfDoc.pages.forEach((page) => {
        console.log(`Page ${page.pageNumber} Tables:`);
        page.tables.forEach((table, index) => {
            console.log(`Table ${index + 1}:`, table.data);
        });
    });
})();

Options

The PdfDocument constructor accepts the following configuration options:

| Option | Type | Default | Description | |-----------------|-----------|---------------|----------------------------------------------| | hasTitles | boolean | true | Indicates whether tables have title rows. | | threshold | number | 1.5 | Sensitivity for grouping rows by y-axis. | | maxStrLength | number | 30 | Maximum string length for table cells. | | ignoreTexts | string[]| [] | Array of texts to ignore during extraction. |

API

PdfDocument

Properties:

  • numPages: Number of pages in the PDF document.
  • pages: Array of parsed pages, each containing:
    • pageNumber: Page number in the PDF.
    • tables: Array of extracted tables.

Methods:

  • load(source: string | Buffer): Promise<void>: Loads and processes the PDF file.

PdfTable

Properties:

  • tableNumber: Identifier for the table.
  • numrows: Number of rows in the table.
  • numcols: Number of columns in the table.
  • data: 2D array representing table data.

Dependencies

Development

To build the project locally:

git clone https://github.com/kanakkholwal/pdf-tables-parser.git
cd pdf-tables-parser
npm install
npm run build

Run tests:

npm test

Contributing

Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request on GitHub.

License

This project is licensed under the ISC License. See the LICENSE file for details.

Support

For issues and suggestions, please visit the GitHub issues page.