The fastest Rust PDF library with text extraction: 0.8ms mean, 100% pass rate on 3,830 PDFs. 5× faster than pdf_extract, 17× faster than oxidize_pdf. Extract, create, and edit PDFs.
// Extract text from every page of a PDF and print it.
// Run: node index.js document.pdf
const{PdfDocument}=require("pdf-oxide");functionmain(){constpath=process.argv[2];if(!path){console.error("Usage: node index.js <file.pdf>");process.exit(1);}constdoc=newPdfDocument(path);constpages=doc.getPageCount();console.log(`Opened:${path}`);console.log(`Pages:${pages}\n`);for(leti=0;i<pages;i++){consttext=doc.extractText(i);console.log(`---Page${i+1}---`);console.log(`${text}\n`);}doc.close();}main();