I thought that, too. But, I turns out that stream() returns void. According to the documentation, stream() streams the PDF to the client , opening a download dialog by default.
Dompdf on button click and load PDF
Hello,
I'm trying to use Dompdf to create a PDF from a view I've created. The goal is, when a user clicks a link on the webpage, the PDF will be generated and loaded in the user's browser (not as an element on the current page, the PDF is rather presented to download/display).
Currently, I have:
Link to direct to PDF
<a role="button" class="btn btn-primary" href="/export/pdf">Export to PDF</a>
Route
Route::get('export/{type}', 'ExportController@export');
Controller
public function export($type)
{
if ($type == "pdf") {
$html = View::make('export.minimal')->with("plan", Plan::first())->render();
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->render();
$dompdf->stream('bp.pdf');
}
}
The view export.minimal is valid a valid blade template: http://pastebin.com/CwimK196
When I click the "Export as PDF" button, however, a blank page is presented. As far as I can tell though the flow should be, in its present form, click on the link, there's a get request that gets directed to the export controller, which then generates the PDF, which should then be presented to the browser because of $dompdf->stream('bp.pdf').
What am I doing wrong here?
I've decided to not include PDF generation on this website because it's not really needed and seems to be too much of a hassle for not much benefit
Please or to participate in this conversation.