TypeScript SDK

The @contexaworks/pdf-to-excel package wraps the async API into a single await call. Zero dependencies.

Requires a RapidAPI key — subscribe here (free tier available).

Quick Start

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

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

const result = await client.pdfToExcel(readFileSync("report.pdf"));

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

Advanced Usage

Progress tracking

For multi-page PDFs, use onProgress to follow extraction 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`);
    }
  },
});

Custom prompts and page ranges

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

// Tell the AI what to focus on
const result2 = await client.pdfToExcel(file, {
  prompt: "Only extract the revenue table, ignore footnotes",
});

Manual polling

Separate submission from result fetching for queue workers or serverless functions.

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

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

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

Browser usage

Pass a File or Blob directly — no Node.js APIs needed.

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

// result.data is an ArrayBuffer — create a download link
const blob = new Blob([result.data], {
  type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
const url = URL.createObjectURL(blob);
TermsPrivacyContact