Phase 1 — Python (klausur-service): 5 monoliths → 36 files - dsfa_corpus_ingestion.py (1,828 LOC → 5 files) - cv_ocr_engines.py (2,102 LOC → 7 files) - cv_layout.py (3,653 LOC → 10 files) - vocab_worksheet_api.py (2,783 LOC → 8 files) - grid_build_core.py (1,958 LOC → 6 files) Phase 2 — Go (edu-search-service, school-service): 8 monoliths → 19 files - staff_crawler.go (1,402 → 4), policy/store.go (1,168 → 3) - policy_handlers.go (700 → 2), repository.go (684 → 2) - search.go (592 → 2), ai_extraction_handlers.go (554 → 2) - seed_data.go (591 → 2), grade_service.go (646 → 2) Phase 3 — TypeScript (admin-lehrer): 45 monoliths → 220+ files - sdk/types.ts (2,108 → 16 domain files) - ai/rag/page.tsx (2,686 → 14 files) - 22 page.tsx files split into _components/ + _hooks/ - 11 component files split into sub-components - 10 SDK data catalogs added to loc-exceptions - Deleted dead backup index_original.ts (4,899 LOC) All original public APIs preserved via re-export facades. Zero new errors: Python imports verified, Go builds clean, TypeScript tsc --noEmit shows only pre-existing errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
100 lines
2.9 KiB
TypeScript
100 lines
2.9 KiB
TypeScript
/**
|
|
* PDF Export Helper Functions
|
|
* Shared formatting utilities for jsPDF document generation
|
|
*/
|
|
|
|
import jsPDF from 'jspdf'
|
|
import { SDKState } from './types'
|
|
import { LABELS_DE } from './export-types'
|
|
|
|
// =============================================================================
|
|
// FORMATTING HELPERS
|
|
// =============================================================================
|
|
|
|
export function formatDate(date: Date | string | undefined): string {
|
|
if (!date) return '-'
|
|
const d = typeof date === 'string' ? new Date(date) : date
|
|
return d.toLocaleDateString('de-DE', {
|
|
day: '2-digit',
|
|
month: '2-digit',
|
|
year: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
})
|
|
}
|
|
|
|
// =============================================================================
|
|
// PAGE LAYOUT HELPERS
|
|
// =============================================================================
|
|
|
|
export function addHeader(doc: jsPDF, title: string, pageNum: number, totalPages: number): void {
|
|
const pageWidth = doc.internal.pageSize.getWidth()
|
|
|
|
// Header line
|
|
doc.setDrawColor(147, 51, 234) // Purple
|
|
doc.setLineWidth(0.5)
|
|
doc.line(20, 15, pageWidth - 20, 15)
|
|
|
|
// Title
|
|
doc.setFontSize(10)
|
|
doc.setTextColor(100)
|
|
doc.text(title, 20, 12)
|
|
|
|
// Page number
|
|
doc.text(`${LABELS_DE.page} ${pageNum}/${totalPages}`, pageWidth - 40, 12)
|
|
}
|
|
|
|
export function addFooter(doc: jsPDF, state: SDKState): void {
|
|
const pageWidth = doc.internal.pageSize.getWidth()
|
|
const pageHeight = doc.internal.pageSize.getHeight()
|
|
|
|
// Footer line
|
|
doc.setDrawColor(200)
|
|
doc.setLineWidth(0.3)
|
|
doc.line(20, pageHeight - 15, pageWidth - 20, pageHeight - 15)
|
|
|
|
// Footer text
|
|
doc.setFontSize(8)
|
|
doc.setTextColor(150)
|
|
doc.text(`Tenant: ${state.tenantId} | ${LABELS_DE.generatedAt}: ${formatDate(new Date())}`, 20, pageHeight - 10)
|
|
}
|
|
|
|
// =============================================================================
|
|
// CONTENT HELPERS
|
|
// =============================================================================
|
|
|
|
export function addSectionTitle(doc: jsPDF, title: string, y: number): number {
|
|
doc.setFontSize(14)
|
|
doc.setTextColor(147, 51, 234) // Purple
|
|
doc.setFont('helvetica', 'bold')
|
|
doc.text(title, 20, y)
|
|
doc.setFont('helvetica', 'normal')
|
|
return y + 10
|
|
}
|
|
|
|
export function addSubsectionTitle(doc: jsPDF, title: string, y: number): number {
|
|
doc.setFontSize(11)
|
|
doc.setTextColor(60)
|
|
doc.setFont('helvetica', 'bold')
|
|
doc.text(title, 25, y)
|
|
doc.setFont('helvetica', 'normal')
|
|
return y + 7
|
|
}
|
|
|
|
export function addText(doc: jsPDF, text: string, x: number, y: number, maxWidth: number = 170): number {
|
|
doc.setFontSize(10)
|
|
doc.setTextColor(60)
|
|
const lines = doc.splitTextToSize(text, maxWidth)
|
|
doc.text(lines, x, y)
|
|
return y + lines.length * 5
|
|
}
|
|
|
|
export function checkPageBreak(doc: jsPDF, y: number, requiredSpace: number = 40): number {
|
|
const pageHeight = doc.internal.pageSize.getHeight()
|
|
if (y + requiredSpace > pageHeight - 25) {
|
|
doc.addPage()
|
|
return 30
|
|
}
|
|
return y
|
|
}
|