Files
pdf-inspector/napi/index.d.ts
T
Abimael MartellandClaude Opus 4.6 506b2a0c70 unify NAPI and Python binding APIs for consistent surface
Both bindings now expose the same 6 function families: process, detect,
classify, extractText, extractTextWithPositions, and extractTextInRegions.
Bumps PyO3 from 0.22 to 0.25 for Python 3.14 support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 11:48:18 -07:00

95 lines
2.9 KiB
TypeScript

/* auto-generated by NAPI-RS */
/* eslint-disable */
/**
* Lightweight PDF classification — returns type, page count, and OCR pages.
* Faster than detectPdf as it skips building the full PdfResult.
* Pages in pagesNeedingOcr are 0-indexed.
*/
export declare function classifyPdf(buffer: Buffer): PdfClassification
/** Fast detection only — no text extraction or markdown. */
export declare function detectPdf(buffer: Buffer): PdfResult
/** Extract plain text from a PDF Buffer. */
export declare function extractText(buffer: Buffer): string
/**
* Extract text within bounding-box regions from a PDF.
*
* For hybrid OCR: layout model detects regions in rendered images,
* this extracts PDF text within those regions — skipping GPU OCR
* for text-based pages.
*
* Each region result includes `needsOcr` — set when the extracted text
* is unreliable (empty, GID-encoded fonts, garbage, encoding issues).
*
* Coordinates are PDF points with top-left origin.
*/
export declare function extractTextInRegions(buffer: Buffer, pageRegions: Array<PageRegions>): Array<PageRegionTexts>
/** Extract text with position information from a PDF Buffer. */
export declare function extractTextWithPositions(buffer: Buffer, pages?: Array<number> | undefined | null): Array<TextItem>
/** A page's regions for text extraction: (page_index_0based, bboxes). */
export interface PageRegions {
page: number
/** Each bbox is [x1, y1, x2, y2] in PDF points, top-left origin. */
regions: Array<Array<number>>
}
/** Extracted text for one page's regions. */
export interface PageRegionTexts {
page: number
regions: Array<RegionText>
}
/** Lightweight PDF classification result. */
export interface PdfClassification {
pdfType: string
pageCount: number
/** 0-indexed page numbers that need OCR. */
pagesNeedingOcr: Array<number>
confidence: number
}
/** Full PDF processing result with markdown and metadata. */
export interface PdfResult {
pdfType: string
markdown?: string
pageCount: number
processingTimeMs: number
/** 1-indexed page numbers that need OCR. */
pagesNeedingOcr: Array<number>
title?: string
confidence: number
isComplexLayout: boolean
pagesWithTables: Array<number>
pagesWithColumns: Array<number>
hasEncodingIssues: boolean
}
/** Process a PDF from a Buffer: detect type, extract text, and convert to Markdown. */
export declare function processPdf(buffer: Buffer, pages?: Array<number> | undefined | null): PdfResult
/** Extracted text for a single region. */
export interface RegionText {
text: string
/** `true` when the text should not be trusted (empty, GID fonts, garbage, encoding issues). */
needsOcr: boolean
}
/** A positioned text item extracted from a PDF. */
export interface TextItem {
text: string
x: number
y: number
width: number
height: number
font: string
fontSize: number
page: number
isBold: boolean
isItalic: boolean
itemType: string
}