|
Download bindings/nodejs/README.md from martinsmessias/rasgapdf: direct link, hf CLI and curl.
- Browser
- Download file 2.41 kB
-
https://huggingface.co/martinsmessias/rasgapdf/resolve/main/bindings/nodejs/README.md
- Command line
-
hf download hf://martinsmessias/rasgapdf/bindings/nodejs/README.md
-
curl -L -o README.md https://huggingface.co/martinsmessias/rasgapdf/resolve/main/bindings/nodejs/README.md
2.41 kB
β‘ RasgaPDF (Node.js)
Ultra-Fast 2D Spatial PDF Parser powered by Pure Rust.
Extract exact physical coordinates (Raw X/Y) or structured blocks & tables with sub-millisecond latency.
π Installation
npm install rasgapdf
Note: Bundles pre-compiled native Rust C-ABI binaries. Works out-of-the-box with optional koffi fast FFI and automatic CLI fallback.
β‘ Two Extraction Modes
β‘ Mode 1: Flat Physical Coordinates (Raw X/Y)
Zero-overhead extraction returning exact physical 2D coordinates [x0, y0, x1, y1] for every text span (~3-8 ms):
const { parseRaw } = require('rasgapdf');
const raw = parseRaw('sample.pdf');
console.log(`Parsed ${raw.total_spans} spans in ${raw.parse_time_ms.toFixed(2)} ms`);
// Iterate through raw physical coordinates
for (const span of raw.spans) {
console.log(`[Page ${span.page}] (${span.x0}, ${span.y0}, ${span.x1}, ${span.y1}) -> "${span.text}"`);
}
π― Mode 2: Hierarchical Structured Document
Extracts visual text blocks, lines, font sizes, and automatically detects matrix tables via column alignment:
const { parsePdf } = require('rasgapdf');
const doc = parsePdf('invoice.pdf', {
detect_tables: true,
min_table_columns: 3
});
console.log(`Total Pages: ${doc.total_pages}`);
for (const page of doc.pages) {
// Access text blocks
for (const block of page.text_blocks) {
console.log(`Block #${block.block_id}: ${block.lines[0].text}`);
}
// Access detected tables
for (const table of page.tables) {
console.log('Table Headers:', table.headers);
console.log('Table Rows:', table.rows);
}
}
π Schema
Returns a deterministic JSON structure representing the exact 2D canvas geometry of the PDF.
RawSpatialDocument
interface RawSpatialDocument {
file_name: string;
total_pages: number;
total_spans: number;
parse_time_ms: number;
spans: Array<{
page: number;
x0: number;
y0: number;
x1: number;
y1: number;
font_size: number;
font_name: string;
text: string;
}>;
}
π License
MIT License. Copyright (c) 2026 Messias Martins.