afpp
Version:
Async Fast PDF Parser for Node.js — dependency-light, TypeScript-first, production-ready.
34 lines (33 loc) • 1.44 kB
TypeScript
import { AfppParseOptions, StreamingResult } from './core';
/**
* Streams PDF pages as images, yielding each page as it's processed.
* Useful for large PDFs where you want to process pages incrementally.
*
* @example
* ```typescript
* for await (const { pageNumber, data } of streamPdf2image('./large.pdf')) {
* await fs.writeFile(`page-${pageNumber}.png`, data);
* }
* ```
*
* @param input - The PDF source (file path, URL, Buffer, or Uint8Array)
* @param options - Optional parsing options
* @yields {StreamingResult<Buffer>} Page data with page number and total count
*/
export declare const streamPdf2image: (input: Buffer | string | Uint8Array | URL, options?: AfppParseOptions) => AsyncGenerator<StreamingResult<Buffer>>;
/**
* Streams PDF pages as text, yielding each page as it's processed.
* Useful for large PDFs where you want to process pages incrementally.
*
* @example
* ```typescript
* for await (const { pageNumber, data } of streamPdf2string('./large.pdf')) {
* console.log(`Page ${pageNumber}: ${data.substring(0, 100)}...`);
* }
* ```
*
* @param input - The PDF source (file path, URL, Buffer, or Uint8Array)
* @param options - Optional parsing options
* @yields {StreamingResult<string>} Page text with page number and total count
*/
export declare const streamPdf2string: (input: Buffer | string | Uint8Array | URL, options?: AfppParseOptions) => AsyncGenerator<StreamingResult<string>>;