Browse Source

fix: 继续调试pdf

大侠咬超人 2 days ago
parent
commit
38861a45ea
1 changed files with 18 additions and 1 deletions
  1. 18 1
      app/Services/ExamPdfExportService.php

+ 18 - 1
app/Services/ExamPdfExportService.php

@@ -1009,7 +1009,15 @@ class ExamPdfExportService
     {
         $tmpHtml = tempnam(sys_get_temp_dir(), 'exam_html_') . '.html';
         $utf8Html = $this->ensureUtf8Html($html);
-        file_put_contents($tmpHtml, $utf8Html);
+        $written = file_put_contents($tmpHtml, $utf8Html);
+
+        Log::info('ExamPdfExportService: HTML文件已创建', [
+            'path' => $tmpHtml,
+            'html_length' => strlen($utf8Html),
+            'written_bytes' => $written,
+            'file_exists' => file_exists($tmpHtml),
+            'file_size' => file_exists($tmpHtml) ? filesize($tmpHtml) : 0,
+        ]);
 
         // 仅使用Chrome渲染
         $chromePdf = $this->renderWithChrome($tmpHtml);
@@ -1089,6 +1097,15 @@ class ExamPdfExportService
         $process->setTimeout(60); // 【优化】减少超时到60秒
         $killSignal = \defined('SIGKILL') ? \SIGKILL : 9;
 
+        Log::info('ExamPdfExportService: Chrome命令准备执行', [
+            'chrome_binary' => $chromeBinary,
+            'html_path' => $htmlPath,
+            'html_exists' => file_exists($htmlPath),
+            'html_size' => file_exists($htmlPath) ? filesize($htmlPath) : 0,
+            'pdf_path' => $tmpPdf,
+            'user_data_dir' => $userDataDir,
+        ]);
+
         try {
             $startedAt = microtime(true);
             $process->start();