/* 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 /** * Detect a vector ruled-line / rectangle grid inside one page region. * * Returns TSR-compatible structure tokens plus crop-pixel cell bboxes, or * `null` when the region does not contain a valid vector grid. * * `pageIdx` is 0-indexed. `regionPdfPtBbox` is `[x1,y1,x2,y2]` in PDF * points with top-left origin. `renderDpi` is the DPI of the crop image that * will consume the returned cell bboxes. */ export declare function detectVectorGridInRegion(buffer: Buffer, pageIdx: number, regionPdfPtBbox: Array, renderDpi: number): VectorGridDetectionJs | null /** * Extract formatted markdown for pages of a PDF, with layout classification * metadata. * * Returns per-page markdown and classification data (tables, columns, * OCR needs) from a single parse. Font statistics are computed from the * full document so header detection is consistent across pages. * * Omit `pages` (or pass `undefined`) to return every page in document * order. Pass an array of 0-indexed page numbers to restrict output to * those pages, in caller-supplied order. */ export declare function extractPagesMarkdown(buffer: Buffer, pages?: Array | undefined | null): PagesExtractionResult /** * Extract markdown tables within bounding-box regions from a PDF. * * Like `extractTextInRegions` but runs table detection on items within each * region and returns markdown pipe-tables instead of flat text. * * When table structure is detected, `text` contains a markdown pipe-table and * `needsOcr` is `false`. When no table is found, `text` is empty and * `needsOcr` is `true` so the caller can fall back to GPU OCR. * * Coordinates are PDF points with top-left origin. */ export declare function extractTablesInRegions(buffer: Buffer, pageRegions: Array): Array /** * Extract markdown tables using externally-supplied structure recovery. * * For each input, pairs structure tokens with cell bboxes (rowspan/colspan * aware), converts each cell bbox from crop image-pixels into page PDF * points, pulls the cell's text from the native PDF, and emits a markdown * pipe-table. * * Returns one markdown string per input, in input order. */ export declare function extractTablesWithStructure(buffer: Buffer, inputs: Array): Array /** * Auto-fallback variant of [`extractTablesWithStructure`]. * * Runs the TSR-hybrid path, checks the resulting cells for known * SLANet detection pathologies, expands multi-row cells in-place when * possible, and otherwise falls back to the heuristic * `extractTablesInRegions` for inputs where the TSR path looks * compromised. * * On clean inputs this returns identical markdown to * `extractTablesWithStructure`; on flagged inputs `fallbackReason` is * set to the recovery path that produced the result. */ export declare function extractTablesWithStructureAuto(buffer: Buffer, inputs: Array): Array /** * Extract structured cells using externally-supplied structure recovery. * * Lower-level sibling of [`extractTablesWithStructure`]: instead of * rendering markdown, returns the resolved cells (row, col, rowspan, * colspan, isHeader, text, pagePtBbox) so callers can drive their own * rendering, debug overlays, or per-cell post-processing. * * Returns one `Array` per input, in input order. */ export declare function extractTablesWithStructureCells(buffer: Buffer, inputs: Array): Array> /** 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): Array /** Extract text with position information from a PDF Buffer. */ export declare function extractTextWithPositions(buffer: Buffer, pages?: Array | undefined | null): Array /** Type of a positioned text item. */ export declare const enum ItemType { Text = 'Text', Image = 'Image', Link = 'Link', FormField = 'FormField' } /** Per-page markdown extraction result. */ export interface PageMarkdownResult { /** 0-indexed page number. */ page: number /** Formatted markdown for this page. */ markdown: string /** `true` when text on this page is unreliable. */ needsOcr: boolean /** Machine-readable OCR reason when the cause is known. */ ocrReason?: string } /** OCR reasons for a single 1-indexed page. */ export interface PageOcrReasons { page: number reasons: Array } /** 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> } /** Extracted text for one page's regions. */ export interface PageRegionTexts { page: number regions: Array } /** Combined per-page markdown extraction and layout classification result. */ export interface PagesExtractionResult { /** Per-page markdown results. */ pages: Array /** 1-indexed pages where tables were detected. */ pagesWithTables: Array /** 1-indexed pages where multi-column layout was detected. */ pagesWithColumns: Array /** 1-indexed pages that need OCR (scanned/image-based). */ pagesNeedingOcr: Array /** Machine-readable OCR reasons by 1-indexed page. */ ocrReasonsByPage: Array /** True if any page has tables or columns. */ isComplex: boolean } /** Lightweight PDF classification result. */ export interface PdfClassification { pdfType: PdfType pageCount: number /** 0-indexed page numbers that need OCR. */ pagesNeedingOcr: Array confidence: number } /** Full PDF processing result with markdown and metadata. */ export interface PdfResult { pdfType: PdfType markdown?: string pageCount: number processingTimeMs: number /** 1-indexed page numbers that need OCR. */ pagesNeedingOcr: Array /** Machine-readable OCR reasons by 1-indexed page. */ ocrReasonsByPage: Array title?: string confidence: number isComplexLayout: boolean pagesWithTables: Array pagesWithColumns: Array hasEncodingIssues: boolean } /** PDF document type classification. */ export declare const enum PdfType { TextBased = 'TextBased', Scanned = 'Scanned', ImageBased = 'ImageBased', Mixed = 'Mixed' } /** Process a PDF from a Buffer: detect type, extract text, and convert to Markdown. */ export declare function processPdf(buffer: Buffer, pages?: Array | 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 /** Machine-readable OCR reason when the cause is known. */ ocrReason?: string } /** One resolved cell from `extractTablesWithStructureCells`. */ export interface StructuredCellJs { /** 0-indexed grid row. */ row: number /** 0-indexed grid column. */ col: number /** 1 for a normal cell. */ rowspan: number /** 1 for a normal cell. */ colspan: number /** `true` when the cell is a `` or sits inside ``. */ isHeader: boolean /** Text extracted from the native PDF for this cell (may be empty). */ text: string /** * Axis-aligned bbox `[x1, y1, x2, y2]` in page PDF-points, top-left * origin. Useful for debug overlays or per-cell post-processing. */ pagePtBbox: Array } /** * One result from `extractTablesWithStructureAuto` — markdown plus a * diagnostic flag identifying which path produced it. * * `fallbackReason` is `null` when the TSR-hybrid path produced the * markdown directly. When stage 1's quality check fires (the cells * look like a SLANet detection pathology — phantom rows or multi-row * content in a single cell), the auto path may expand the TSR cells * in-place or run the heuristic table extractor on the same region. * `fallbackReason` carries the diagnostic label (for example * `"multi_row_in_cell_expanded"` or `"phantom_empty_row"`). */ export interface TableExtractionResultJs { markdown: string fallbackReason?: string } /** 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 /** * Underline detected geometrically (drawn rule/thin rect under the * baseline) — PDFs carry no underline font flag. */ isUnderline: boolean /** * Strikeout detected geometrically (rule crossing the glyphs at mid * x-height). */ isStrikeout: boolean itemType: ItemType /** URL for link items, `None` for other types. */ linkUrl?: string } /** * One cropped table region plus its raw structure-recovery output, for * `extractTablesWithStructure`. * * `structureTokens` and `cellBboxes` are typically produced by an external * table-structure recognition model (e.g. SLANet on PaddleOCR) running on * a rendered crop of the page. pdf-inspector uses the structure to lay out * the cells and pulls the cell text from the native PDF — no OCR involved. */ export interface TsrTableInputJs { /** 0-indexed page number where the crop was taken from. */ page: number /** * Crop bbox on the page, `[x1, y1, x2, y2]` in PDF points with * top-left origin. */ cropPdfPtBbox: Array /** DPI the crop image was rendered at (e.g. `200.0`). */ renderDpi: number /** Raw structure tokens emitted by the TSR model, in document order. */ structureTokens: Array /** * One bbox per cell (in document order). May be 4-element * `[x1,y1,x2,y2]` or 8-element 4-corner polygon, in crop image-pixel * space. */ cellBboxes: Array> } /** Vector-grid detection result compatible with `extractTablesWithStructure*`. */ export interface VectorGridDetectionJs { structureTokens: Array cellBboxes: Array> }