components->info('Generazione HTML della guida...'); $html = View::make('help.pdf', ['appName' => $appName])->render(); $tmpHtml = tempnam(sys_get_temp_dir(), 'help_') . '.html'; file_put_contents($tmpHtml, $html); $output = $this->option('output'); if (!$output) { $output = storage_path('app/help-guida.pdf'); } $this->components->info('Conversione in PDF via Chromium...'); $cmd = sprintf( '/usr/bin/chromium --headless --no-sandbox --disable-gpu --print-to-pdf=%s %s 2>&1', escapeshellarg($output), escapeshellarg('file://' . $tmpHtml) ); exec($cmd, $execOutput, $exitCode); unlink($tmpHtml); if ($exitCode !== 0) { $this->components->error('Errore Chromium: ' . implode("\n", $execOutput)); return Command::FAILURE; } $size = filesize($output); $this->components->success(sprintf( 'PDF generato: %s (%.2f MB)', $output, $size / 1024 / 1024 )); return Command::SUCCESS; } }