1
2
3
4
5
6
7
8
9
10
11
import { PDFExtract, PDFExtractOptions } from "npm:pdf.js-extract";
export default async function pdfExtractText(data: ArrayBuffer) {
const pdfExtract = new PDFExtract();
// const req = await fetch("https://morth.nic.in/sites/default/files/dd12-13_0.pdf");
// const data = await req.arrayBuffer();
const options: PDFExtractOptions = {}; /* see below */
const pdf = await pdfExtract.extractBuffer(data, options);
const text = pdf.pages.flatMap(p => p.content).map(c => c.str).join("\n");
return text;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
September 3, 2024