Add PDF translation API, utilities, docs, and config
Introduces core backend and frontend infrastructure for a PDF translation interface. Adds API endpoints for translation, PDF testing, and AI provider testing; implements PDF text extraction, cost tracking, and pricing logic in the lib directory; adds reusable UI components; and provides comprehensive documentation (SDD, environment setup, Claude instructions). Updates Tailwind and global styles, and includes a sample test PDF and configuration files.
This commit is contained in:
55
create-test-pdf.js
Normal file
55
create-test-pdf.js
Normal file
@@ -0,0 +1,55 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user