const fs = require('fs') const { PDFDocument, StandardFonts, rgb } = require('pdf-lib') async function createTestPDF() { try { // Create a new PDF document using pdf-lib (same library we use for processing) const pdfDoc = await PDFDocument.create() // Add a page const page = pdfDoc.addPage() const { width, height } = page.getSize() // Embed a standard font const font = await pdfDoc.embedFont(StandardFonts.Helvetica) // Add text content (using only ASCII characters to ensure compatibility) const fontSize = 16 let yPosition = height - 100 const texts = [ 'PDF Text Extraction Test', 'This is a test document for PDF text extraction.', 'Line 1: Hello World', 'Line 2: Testing PDF processing', 'Line 3: Multiple line text extraction', 'This PDF was created using pdf-lib.', 'It should have extractable text content.' ] for (const text of texts) { page.drawText(text, { x: 50, y: yPosition, size: fontSize, font: font, color: rgb(0, 0, 0), }) yPosition -= fontSize + 10 } // Save the PDF const pdfBytes = await pdfDoc.save() // Write to file fs.writeFileSync('test-document.pdf', pdfBytes) console.log('Test PDF created successfully: test-document.pdf') console.log(`PDF size: ${pdfBytes.length} bytes`) } catch (error) { console.error('Error creating PDF:', error) } } createTestPDF()