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 🙏

© 2024 – Pkg Stats / Ryan Hefner

pdf-seek

v1.0.0

Published

A simple library for extracting text from PDFs

Downloads

2

Readme

PDF Seek

Simple PDF data extraction package to provide a few useful wrappers around existing PDF parsers for JS

Getting started

Install from NPM:

npm install pdf-seek

Usage

import { PDFSeek } from 'pdf-seek';

// Load in a pdf file
const pdfSeaker = await PDFSeaker.fromFile('./my.pdf');

// Do operations on it using API
const text = pdfSeaker
    .jumpToString('my string')
    .step()
    .step()
    .read()

// Profit?

API

The seaker automatically breaks the PDF down into a stream of elements, which can be navigated using the API. Depending on how the PDF was constructed, an elements can be a single character, a word, a line, or a paragraph.

To help with navigation in the case where the PDF has small elements, the seaker has an option for joinDataByValue, which will join elements together if they have the same y value on the page and occur sequentially. This is useful for PDFs where each character is a separate element.

Internally, the pdf-seeker object has a pointer to the current element, which is updated by the API methods. The pointer is initially set to the first element in the PDF.

step

  • Moves the current position in the PDF by a single element.

stepBack

  • Moves the current position in the PDF back by a single element.

read

  • Returns the current element as a string.

readNotEmpty

  • If the current element is empty, moves the pointer forward until it finds a non-empty element, then returns that element as a string.

readContent

  • Returns the current element as an object with X, Y, and Value properties.

isComplete

  • Returns true if the current position in the PDF is at the end of the PDF.

readMany

  • Returns an array of elements, starting from the current position in the PDF, and moving forward by the specified number of elements.

jumpToString

  • Moves the current position in the PDF to the first element that matches the specified string. If the string is not found, throws an error

readTillString

  • Returns an array of elements, starting from the current position in the PDF, and moving forward until the specified string is found. If the string is not found, throws an error

readRow

  • Returns an array of elements, starting from the current position in the PDF, and moving forward until the end of the row is found. The end of the row is determined when there are no longer any elemeents of the same height within a certain index count ahead of it. The distance can be specified as an option when creating the PDFSeeker object.

readAllRows

  • Returns an array of arrays of elements, where each array is a row of elements. The rows are determined by the same method as readRow.

readAllRowsUntil

  • Returns an array of arrays of elements, where each array is a row of elements. The rows are determined by the same method as readRow, but the process stops when the specified string is found.

joinDataByValue

  • Joins elements together if they have the same y value on the page and occur sequentially. This is useful for PDFs where each character is a separate element.