|
|
@@ -1504,17 +1504,24 @@ class Report extends Component
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Log::info("Total attachment pages: {$totalAttachmentPages}");
|
|
|
+ $separatorPageCount = 0;
|
|
|
+ if ($hasPdfAttachments) {
|
|
|
+ $separatorPageCount = 1;
|
|
|
+ Log::info("Separator page count: {$separatorPageCount}");
|
|
|
+ }
|
|
|
|
|
|
- $data['attachment_pages'] = $totalAttachmentPages;
|
|
|
- $pdf = Pdf::loadView('pdf.verbale', array('data' => $data));
|
|
|
- $pdf->render();
|
|
|
+ $totalAttachmentPagesWithSeparator = $totalAttachmentPages + $separatorPageCount;
|
|
|
+ Log::info("Total attachment pages (including separator): {$totalAttachmentPagesWithSeparator}");
|
|
|
|
|
|
- $mainPageCount = $pdf->getDomPDF()->getCanvas()->get_page_count();
|
|
|
+ $data['total_pages'] = 0;
|
|
|
+ $initialPdf = Pdf::loadView('pdf.verbale', array('data' => $data));
|
|
|
+ $initialPdf->render();
|
|
|
+ $mainPageCount = $initialPdf->getDomPDF()->getCanvas()->get_page_count();
|
|
|
Log::info("Main PDF has {$mainPageCount} pages");
|
|
|
|
|
|
- $totalPages = $mainPageCount + $totalAttachmentPages;
|
|
|
- Log::info("Total pages (main + attachments): {$totalPages}");
|
|
|
+ $totalPages = $mainPageCount + $totalAttachmentPages + $separatorPageCount;
|
|
|
+ Log::info("Total pages breakdown: Main={$mainPageCount}, Attachments={$totalAttachmentPages}, Separator={$separatorPageCount}");
|
|
|
+ Log::info("Total pages (main + attachments + separator): {$totalPages}");
|
|
|
|
|
|
$data['total_pages'] = $totalPages;
|
|
|
$pdf = Pdf::loadView('pdf.verbale', array('data' => $data));
|
|
|
@@ -1556,6 +1563,9 @@ class Report extends Component
|
|
|
$success = $this->mergeWithGhostScript($pdfFiles, $outputPath);
|
|
|
|
|
|
if ($success) {
|
|
|
+ $finalPageCount = $this->countPdfPages($outputPath);
|
|
|
+ Log::info("Final merged PDF has {$finalPageCount} pages (expected around: {$totalPages})");
|
|
|
+
|
|
|
Log::info("PDF merge successful, returning merged file");
|
|
|
$pdfContent = file_get_contents($outputPath);
|
|
|
|