Skip to content

Commit

Permalink
Update DompdfWrapper.php
Browse files Browse the repository at this point in the history
To be able to use `callback` render must be called after `dispatch`

https://github.com/dompdf/dompdf/wiki/Usage#callbacks
  • Loading branch information
kl3sk authored and core23 committed Jan 30, 2024
1 parent 3937e1a commit fafffa5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Wrapper/DompdfWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ public function streamHtml(string $html, string $filename, array $options = []):
{
$pdf = $this->dompdfFactory->create($options);
$pdf->loadHtml($html);
$pdf->render();

if ($this->eventDispatcher instanceof EventDispatcherInterface) {

Check warning on line 44 in src/Wrapper/DompdfWrapper.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.3)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ { $pdf = $this->dompdfFactory->create($options); $pdf->loadHtml($html); - if ($this->eventDispatcher instanceof EventDispatcherInterface) { + if (true) { $event = new StreamEvent($pdf, $filename, $html); $this->eventDispatcher->dispatch($event, DompdfEvents::STREAM); }
$event = new StreamEvent($pdf, $filename, $html);
$this->eventDispatcher->dispatch($event, DompdfEvents::STREAM);
}

$pdf->render();
$pdf->stream($filename, $options);
}

public function getPdf(string $html, array $options = []): string
{
$pdf = $this->dompdfFactory->create($options);
$pdf->loadHtml($html);
$pdf->render();

if ($this->eventDispatcher instanceof EventDispatcherInterface) {

Check warning on line 58 in src/Wrapper/DompdfWrapper.php

View workflow job for this annotation

GitHub Actions / run / Mutation Tests (8.3)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ { $pdf = $this->dompdfFactory->create($options); $pdf->loadHtml($html); - if ($this->eventDispatcher instanceof EventDispatcherInterface) { + if (true) { $event = new OutputEvent($pdf, $html); $this->eventDispatcher->dispatch($event, DompdfEvents::OUTPUT); }
$event = new OutputEvent($pdf, $html);
$this->eventDispatcher->dispatch($event, DompdfEvents::OUTPUT);
}

$pdf->render();
$out = $pdf->output();

if (null === $out) {
Expand Down

0 comments on commit fafffa5

Please sign in to comment.