// Test script til at teste OCR funktionalitet direkte const ocrService = require('./backend/src/services/ocrService'); const path = require('path'); async function testOCR() { try { console.log('Starting OCR test...'); const pdfPath = '/home/alex/git/tilbudgivern/frontend/tilbudspdf/Tilbud-1.pdf'; console.log('Testing with:', pdfPath); // Test hvis filen eksisterer const fs = require('fs'); if (!fs.existsSync(pdfPath)) { console.error('PDF file not found:', pdfPath); return; } console.log('PDF file exists, starting OCR...'); // Test OCR extraction const ocrText = await ocrService.extractTextFromPDF(pdfPath); console.log('OCR Text length:', ocrText.length); console.log('OCR Text preview:', ocrText.substring(0, 200) + '...'); // Test price data extraction const priceData = await ocrService.extractPriceDataFromText(ocrText, 'material'); console.log('Price data:', JSON.stringify(priceData, null, 2)); } catch (error) { console.error('OCR test failed:', error); } } testOCR();