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

@contexaworks/pdf-to-excel

v0.2.1

Published

Convert PDF documents to Excel spreadsheets with AI-powered table extraction

Readme

@contexaworks/pdf-to-excel

Convert PDF documents to Excel spreadsheets (.xlsx) with AI-powered table extraction. Automatically detects tables, headers, column types, and multi-page layouts.

Powered by the Contexa PDF to Excel API on RapidAPI.

Install

npm install @contexaworks/pdf-to-excel

Quick Start

Get your API key from RapidAPI — subscribe to a plan and copy your X-RapidAPI-Key from any endpoint page.

import { ContexaPdfToExcel } from "@contexaworks/pdf-to-excel";
import { readFileSync, writeFileSync } from "fs";

const client = new ContexaPdfToExcel({
  apiKey: "your-rapidapi-key",
});

// Convert a PDF to Excel — returns the .xlsx binary
const result = await client.pdfToExcel(readFileSync("report.pdf"));

writeFileSync("report.xlsx", Buffer.from(result.data));
console.log(`Done in ${result.processingTimeMs}ms`);

Usage

File Input

The SDK accepts multiple file input formats:

// Buffer / Uint8Array (Node.js)
await client.pdfToExcel(readFileSync("file.pdf"));

// File / Blob (browser)
const input = document.querySelector<HTMLInputElement>("#file-input");
await client.pdfToExcel(input.files[0]);

// Base64 string
await client.pdfToExcel({
  base64: "JVBERi0xLjQg...",
  mimeType: "application/pdf",
  fileName: "report.pdf",
});

Extract Specific Pages

const result = await client.pdfToExcel(file, {
  pages: "1-5", // only extract pages 1 through 5
});

Custom Extraction Prompt

Guide the AI on what to extract:

const result = await client.pdfToExcel(file, {
  prompt: "Only extract the revenue table, ignore footnotes",
});

Progress Tracking

For large PDFs, track extraction progress page by page:

const result = await client.pdfToExcel(file, {
  onProgress: (job) => {
    const p = job.result?.progress;
    if (p) {
      console.log(`Page ${p.currentPage}/${p.totalPages} — ${p.tablesFound} tables found`);
    }
  },
});

Manual Polling

If you prefer to handle polling yourself (e.g. in a queue worker):

// Submit the job without waiting
const { jobId } = await client.pdfToExcel(file, { poll: false });

// Check status later
const job = await client.getJob(jobId);
console.log(job.status); // "processing" | "completed" | "failed"

// Fetch the result when ready
const response = await client.getJobResult(jobId);
const xlsx = Buffer.from(await response.arrayBuffer());

Webhook Callback

Get notified when extraction completes instead of polling:

const { jobId } = await client.pdfToExcel(file, {
  poll: false,
  callbackUrl: "https://your-server.com/webhook",
});
// Your webhook receives: { jobId, status, processingTimeMs }

What It Extracts

The AI handles complex PDF layouts including:

  • Multi-page tables — tables that span across pages are automatically merged
  • Multi-row headers — grouped/spanning column headers are preserved
  • Column types — numbers, dates, currencies, percentages detected automatically
  • Merged cells — vertically merged cells are reconstructed in the Excel output
  • Multiple tables — each table gets its own worksheet

API Reference

new ContexaPdfToExcel(options)

| Option | Type | Required | Description | |-----------|----------|----------|--------------------------------------------------| | apiKey | string | Yes | Your RapidAPI key | | baseUrl | string | No | API base URL (default: RapidAPI proxy) |

client.pdfToExcel(file, options?)

| Option | Type | Default | Description | |---------------|-------------------------|---------|------------------------------------| | prompt | string | — | Custom extraction instructions | | pages | string | — | Page range (e.g. "1-5") | | poll | boolean | true | Wait for completion | | onProgress | (job: Job) => void | — | Progress callback | | pollInterval| number | 2000 | Polling interval in ms | | callbackUrl | string | — | Webhook URL for completion |

Returns ExcelResult (when poll: true) or AsyncSubmitResult (when poll: false).

client.getJob(id)

Returns the current status of a job.

client.getJobResult(id)

Returns the raw Response — for Excel jobs this contains the .xlsx binary.

RapidAPI Setup

  1. Go to Contexa PDF to Excel on RapidAPI
  2. Subscribe to a plan (free tier available)
  3. Copy your X-RapidAPI-Key from any endpoint page
  4. Pass it as apiKey when creating the client

License

MIT