#!/usr/bin/env tsx import * as fs from 'fs'; import * as path from 'path'; import { extractPlaceholdersWithPdfium } from '../lib/odentas-sign/placeholders'; async function main() { const pdfPath = path.join(process.cwd(), 'test-contrat.pdf'); console.log('Lecture du PDF de test:', pdfPath); if (!fs.existsSync(pdfPath)) { console.error('PDF de test introuvable!'); process.exit(1); } const pdfBuffer = fs.readFileSync(pdfPath); console.log(`PDF chargé: ${pdfBuffer.length} bytes (${Math.round(pdfBuffer.length / 1024)} KB)\n`); console.log('=== Extraction avec Pdfium ===\n'); const positions = await extractPlaceholdersWithPdfium(pdfBuffer); console.log('\n=== RÉSULTATS ==='); console.log(`Nombre de positions trouvées: ${positions.length}\n`); positions.forEach((pos, index) => { console.log(`Position ${index + 1}:`); console.log(` Label: ${pos.label}`); console.log(` Role: ${pos.role}`); console.log(` Page: ${pos.page}`); console.log(` Position: x=${pos.x.toFixed(1)}%, y=${pos.y.toFixed(1)}%`); console.log(` Dimensions: w=${pos.width.toFixed(1)}%, h=${pos.height.toFixed(1)}%`); if (pos.text) { console.log(` Texte: ${pos.text}`); } console.log(''); }); } main().catch(console.error);