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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@papra/lecture

v0.4.0

Published

A simple library to extract text from files

Readme

@papra/lecture

@papra/lecture is a robust and lightweight library for extracting text content from various file formats. Whether you're processing Document for indexing or for LLM readability, this library simplifies the task of reading text content programmatically.

This lib is used in the Papra project to extract text from various file formats.

Features

  • Wide Format Support: Extract text from PDFs, plain text files, YAML, Markdown, CSV, and all text/* MIME types.
  • Promise-based API: Designed with asynchronous functions to provide a seamless integration experience.
  • Extensible and Modular: Built with future compatibility in mind. Support for more file formats is on the way.
  • Error Handling: Provides detailed error information when extraction fails.

Supported File Formats

Currently, @papra/lecture supports the following file formats:

  • PDF
  • Plain Text (e.g., .txt)
  • YAML (e.g., .yaml, .yml)
  • Markdown (e.g., .md)
  • CSV
  • All text/* MIME types
  • Images OCR (e.g., .jpg, .png, .gif)
  • Coming soon: Microsoft Office Documents (e.g., .docx, .xlsx, .pptx)
  • Coming soon: eBooks (e.g., .epub, .mobi)

We are actively working on adding support for more file formats. Stay tuned for updates!

Installation

To install the package, use npm or yarn:

pnpm install @papra/lecture

npm install @papra/lecture

yarn add @papra/lecture

Usage

Importing the Library

You can import the library using ES Modules or CommonJS syntax:

// ES Modules
import { extractText } from '@papra/lecture';
// or CommonJS
const { extractText } = require('@papra/lecture');

const { textContent } = await extractText({arrayBuffer: file, mimeType: 'application/pdf'});

console.log('Extracted Text:', textContent);

Functions

extractText

Extracts text from an arrayBuffer using its MIME type.

Example:

const file = await fetch('example.pdf').then(res => res.arrayBuffer());
const mimeType = 'application/pdf';

const { textContent } = await extractText({ arrayBuffer: file, mimeType });

console.log('Extracted Text:', textContent);

extractTextFromBlob

Extracts text from a Blob object (e.g., files or data retrieved from APIs).

const blob = new Blob(['Hello, World!'], { type: 'text/plain' });

const { textContent } = await extractTextFromBlob({ blob });

console.log('Extracted Text:', textContent);

extractTextFromFile

Extracts text from a file using its MIME type.

const file = document.querySelector('#file-input').files[0]; // HTML File Input

const { textContent } = await extractTextFromFile({ file });

console.log('Extracted Text:', textContent);

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests. Let's make @papra/lecture better together.

Testing

You can run the tests with the following command:

# one shot
pnpm run test

# watch mode
pnpm run test:watch

Automated fixtures are run against the fixtures directory. Add files to this directory in the format [0-9]{3}.ext like 001.js following the incremental pattern. The test runner will automatically pick up the new fixtures and generate a [0-9]{3}.expected, adding the expected output.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Credits and Acknowledgements

This project is crafted with ❤️ by Corentin Thomasset. If you find this project helpful, please consider supporting my work.