npm-pdfreader
🚜 Parse text and tables from PDF files. (by adrienjoly)
polyfill
Set of all Javascript polyfills [Moved to: https://github.com/behnammodi/polyfill] (by uxitten)
npm-pdfreader | polyfill | |
---|---|---|
3 | 1 | |
581 | 144 | |
- | - | |
3.9 | - | |
4 months ago | about 2 years ago | |
HTML | JavaScript | |
MIT License | MIT License |
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
npm-pdfreader
Posts with mentions or reviews of npm-pdfreader.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2024-03-12.
-
Parsing PDFs in Node.js
pdfreader is another tool that converts PDFs from binary to JSON format. Underneath, it uses pdf2json. Unlike the packages we have seen so far, which don't support tabular data, this package does so with automatic column detection and rule-based parsing.
- npm-pdfreader: Parse text and tables from PDF files.
- Pdfreader: Read text and parse tables from PDF files
polyfill
Posts with mentions or reviews of polyfill.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2024-03-12.
-
Parsing PDFs in Node.js
import { PdfReader, TableParser } from "pdfreader"; const filename = "./uploads/table.pdf"; const nbCols = 2; const cellPadding = 40; const columnQuantitizer = (item) => parseFloat(item.x) >= 20; // polyfill for String.prototype.padEnd() // https://github.com/uxitten/polyfill/blob/master/string.polyfill.js // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat if (!String.prototype.padEnd) { String.prototype.padEnd = function padEnd(targetLength, padString) { targetLength = targetLength >> 0; //floor if number or convert non-number to 0; padString = String(padString || " "); if (this.length > targetLength) { return String(this); } else { targetLength = targetLength - this.length; if (targetLength > padString.length) { padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed } return String(this) + padString.slice(0, targetLength); } }; } const padColumns = (array, nb) => Array.apply(null, { length: nb }).map((val, i) => array[i] || []); const mergeCells = (cells) => (cells || []).map((cell) => cell.text).join(""); const formatMergedCell = (mergedCell) => mergedCell.substr(0, cellPadding).padEnd(cellPadding, " "); const renderMatrix = (matrix) => (matrix || []) .map( (row, y) => "| " + padColumns(row, nbCols) .map(mergeCells) .map(formatMergedCell) .join(" | ") + " |" ) .join("\n"); var table = new TableParser(); new PdfReader().parseFileItems(filename, function (err, item) { if (err) console.error(err); else if (!item || item.page) { // end of file, or page console.log(renderMatrix(table.getMatrix())); item?.page && console.log("PAGE:", item.page); table = new TableParser(); // new/clear table for next page } else if (item.text) { // accumulate text items into rows object, per line table.processItem(item, columnQuantitizer(item)); } });
What are some alternatives?
When comparing npm-pdfreader and polyfill you can also consider the following projects:
Formal-stack-pdfs - Make pdf from image , markdown and more is coming...
pdf-parse
parse5 - HTML parsing/serialization toolset for Node.js. WHATWG HTML Living Standard (aka HTML5)-compliant.
ImportJSON - Import JSON into Google Sheets, this library adds various ImportJSON functions to your spreadsheet
HTMLKit - An Objective-C framework for your everyday HTML needs.
RatS - Movie Ratings Synchronization with Python
Oxylabs - Web scraping, data parsing and automation tutorials.