From 581d377a175c19282b5f26192f2fb259ee9b7ca3 Mon Sep 17 00:00:00 2001 From: kl3sk Date: Thu, 25 Jan 2024 16:39:42 +0100 Subject: [PATCH] Update DompdfWrapper.php To be able to use `callback` render must be called after `dispatch` https://github.com/dompdf/dompdf/wiki/Usage#callbacks --- src/Wrapper/DompdfWrapper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Wrapper/DompdfWrapper.php b/src/Wrapper/DompdfWrapper.php index 00b4923..abcedd7 100644 --- a/src/Wrapper/DompdfWrapper.php +++ b/src/Wrapper/DompdfWrapper.php @@ -40,13 +40,13 @@ public function streamHtml(string $html, string $filename, array $options = []): { $pdf = $this->dompdfFactory->create($options); $pdf->loadHtml($html); - $pdf->render(); if ($this->eventDispatcher instanceof EventDispatcherInterface) { $event = new StreamEvent($pdf, $filename, $html); $this->eventDispatcher->dispatch($event, DompdfEvents::STREAM); } + $pdf->render(); $pdf->stream($filename, $options); } @@ -54,13 +54,13 @@ public function getPdf(string $html, array $options = []): string { $pdf = $this->dompdfFactory->create($options); $pdf->loadHtml($html); - $pdf->render(); if ($this->eventDispatcher instanceof EventDispatcherInterface) { $event = new OutputEvent($pdf, $html); $this->eventDispatcher->dispatch($event, DompdfEvents::OUTPUT); } + $pdf->render(); $out = $pdf->output(); if (null === $out) {