diff --git a/module/knowledgecenter_update/Script/migrate_old_wiki.php b/module/knowledgecenter_update/Script/migrate_old_wiki.php index 767f895..01b2fc1 100644 --- a/module/knowledgecenter_update/Script/migrate_old_wiki.php +++ b/module/knowledgecenter_update/Script/migrate_old_wiki.php @@ -162,6 +162,18 @@ function get_article_files(int $cid): array { function extract_pdf_text(string $filePath): string { if (!file_exists($filePath) || filesize($filePath) === 0) return ''; + + // pdftotext ist robuster bei gesicherten PDFs (nur Kopier-Schutz, kein Passwort) + $pdftotext = trim(shell_exec('which pdftotext 2>/dev/null') ?? ''); + if ($pdftotext !== '') { + $escaped = escapeshellarg($filePath); + $out = shell_exec("$pdftotext -nopgbrk $escaped - 2>/dev/null"); + if ($out !== null && strlen(trim($out)) > 10) { + return preg_replace('/\s+/', ' ', trim($out)); + } + } + + // Fallback: pdfparser try { $parser = new \Smalot\PdfParser\Parser(); $pdf = $parser->parseFile($filePath);