I need some help here with OctoberCMS using DynamicPDF Plugin on front end:
Have the following October CMS Page:
title = "Dues"
url = "/account/dues"
layout = "profile"
is_hidden = 0
==
<?php
use Corp\Proj\Models\Account;
use Renatio\DynamicPDF\Classes\PDF;
use Renatio\DynamicPDF\Models\PDFTemplate;
function onInvoiceDownload()
{
$id = post("id");
$account = Account::find($id);
return PDF::loadTemplate("proj:invoice", ['data' => $account])->stream();
}
?>
==
{% set account = user.account %}
<button data-request="onInvoiceDownload" data-request-data="id: {{ account.id }}" class="btn btn-default">
<i class="fa fa-download"></i> Download
</button>
The expected behaviour would be to download the PDF File when clicking the button, but it loads and dies silently ... doing nothing visible. Tried with ->download()
and ->stream()
but nothing works!
Any ideas ?