import { readFile } from 'node:fs/promises';
import { countWords, readPdfText, withPdfDocument } from '../utils.js';
export async function parsePdf(filePath) {
    const buffer = await readFile(filePath);
    const { text, total } = await withPdfDocument(buffer, readPdfText);
    const words = countWords(text);
    return {
        fileType: 'PDF',
        metrics: { words, pages: total },
        confidence: {
            // A PDF stores positioned glyphs, not words, so a word count is
            // reconstructed from layout and can disagree with a human one. The page
            // total comes from the document structure and does not.
            words: 'estimated',
            pages: 'exact',
        },
    };
}
//# sourceMappingURL=pdf.js.map