ControleOnline /
api-platform-common
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ControleOnline\Service; |
||
| 4 | |||
| 5 | use Symfony\Component\HttpFoundation\HeaderUtils; |
||
|
0 ignored issues
–
show
|
|||
| 6 | use Symfony\Component\HttpFoundation\StreamedResponse; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\HttpFoundation\StreamedResponse was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 7 | use Dompdf\Dompdf; |
||
|
0 ignored issues
–
show
The type
Dompdf\Dompdf was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 8 | use Dompdf\Options; |
||
|
0 ignored issues
–
show
The type
Dompdf\Options was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 9 | |||
| 10 | class PdfService |
||
| 11 | { |
||
| 12 | |||
| 13 | |||
| 14 | public function showPdf($content) |
||
| 15 | { |
||
| 16 | $response = new StreamedResponse(function () use ($content) { |
||
| 17 | fputs(fopen('php://output', 'wb'), $content); |
||
| 18 | }); |
||
| 19 | |||
| 20 | $response->headers->set('Content-Type', 'application/pdf'); |
||
| 21 | |||
| 22 | $disposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_INLINE, 'contract.pdf'); |
||
| 23 | |||
| 24 | $response->headers->set('Content-Disposition', $disposition); |
||
| 25 | |||
| 26 | return $response; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function convertHtmlToPdf($html): string |
||
| 30 | { |
||
| 31 | $options = new Options(); |
||
| 32 | $options->set('isRemoteEnabled', true); |
||
| 33 | |||
| 34 | $dompdf = new Dompdf($options); |
||
| 35 | $dompdf->loadHtml($html); |
||
| 36 | $dompdf->setPaper('A4'); |
||
| 37 | $dompdf->render(); |
||
| 38 | $html = $dompdf->output(); |
||
| 39 | |||
| 40 | return $html; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths