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