| @@ 52-64 (lines=13) @@ | ||
| 49 | /** |
|
| 50 | * {@inheritdoc} |
|
| 51 | */ |
|
| 52 | public function streamHtml(string $html, string $filename, array $options = []): void |
|
| 53 | { |
|
| 54 | $pdf = $this->dompdfFactory->create($options); |
|
| 55 | $pdf->loadHtml($html); |
|
| 56 | $pdf->render(); |
|
| 57 | ||
| 58 | if ($this->eventDispatcher instanceof EventDispatcherInterface) { |
|
| 59 | $event = new GenericEvent($pdf, ['filename' => $filename, 'html' => $html]); |
|
| 60 | $this->eventDispatcher->dispatch(Events::STREAM, $event); |
|
| 61 | } |
|
| 62 | ||
| 63 | $pdf->stream($filename); |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * {@inheritdoc} |
|
| @@ 69-81 (lines=13) @@ | ||
| 66 | /** |
|
| 67 | * {@inheritdoc} |
|
| 68 | */ |
|
| 69 | public function getPdf(string $html, array $options = []): string |
|
| 70 | { |
|
| 71 | $pdf = $this->dompdfFactory->create($options); |
|
| 72 | $pdf->loadHtml($html); |
|
| 73 | $pdf->render(); |
|
| 74 | ||
| 75 | if ($this->eventDispatcher instanceof EventDispatcherInterface) { |
|
| 76 | $event = new GenericEvent($pdf, ['html' => $html]); |
|
| 77 | $this->eventDispatcher->dispatch(Events::OUTPUT, $event); |
|
| 78 | } |
|
| 79 | ||
| 80 | return $pdf->output(); |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||