send image from presenter to latte

thcom
Backer | 89
+
0
-

hi I try to generate Invoice with qr code

i use very primitive way to send qr image to template

        $qrInvoice->saveQRCodeImage('/var/www/html/faktury/temp/qr.png', 'png', 200, 10);

and

	<img src = "{$basePath}/../temp/qr.png">

is any way to send image with qr code send from presenter to latte teplate better way ?

thank you !

Last edited by thcom (2022-04-01 19:08)

Pepino
Member | 103
+
0
-

@thcom what is your problem? Qr not generate or display?

petr.pavel
Member | 531
+
0
-

You can define a separate presenter action for generating and displaying the QR code.

class InvoicePresenter
{
  public function renderInvoice(int $id)
  {
     // this is your current code but without the QR code generation
     // use Nette Cache for storing the result if performance is an issue
  }

  public function renderQr(int $id)
  {
     // here's the QR generation code with direct output, not into a file
     $qrInvoice->printQRCodeImage('png', 200, 10);
  }
<img n:src="qr $id">
Michalek
Member | 200
+
0
-

I think thcom wants something like dataStream, to avoid generating unnecessary image to temp?

https://latte.nette.org/en/filters#…

Last edited by Michalek (2022-04-02 10:39)

thcom
Backer | 89
+
0
-

Michalek wrote:

I think thcom wants something like dataStream, to avoid generating unnecessary image to temp?

https://latte.nette.org/en/filters#…

YES !

I am dumb, i found this page, but I did niot understand

now I understand !

thank you