8000 Update README.md by ThibaultPelloquin · Pull Request #3483 · dompdf/dompdf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update README.md #3483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ThibaultPelloquin
Copy link

Adding info about using directly dompdf in Symfony without bundle

Adding info about using directly dompdf in Symfony without bundle
@Ayush9054
Copy link
Ayush9054 commented Jul 12, 2024
<?php
require 'vendor/autoload.php';

use Dompdf\Dompdf;
use Dompdf\Options;

$options = new Options();
$options->set('isHtml5ParserEnabled', true);

$dompdf = new Dompdf($options);


$html = '<p>There is a less-than character after this word < Is it rendered?</p>';
$dompdf->loadHtml($html);

$dompdf->setPaper('A4', 'portrait');

$dompdf->render();

$dompdf->stream();
?>

@Ayush9054
Copy link

THAT WAS A DUMMY COMMENT

Comment on lines +263 to +267
// Preventing the ControllerDoesNotReturnResponseException
$response = new StreamedResponse();
$response->setCallback(function () use ($dompdf, $pdfFilename): void {
$dompdf->stream($pdfFilename, ['Attachment' => true]);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid this exception, instead use the Dompdf::stream, you can build your own response with Dompdf::output;

Example:
https://gist.github.com/ronei-kunkel/fdf6d1006f80a210ffce809608afc314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0