0

So this is pretty well documented in the library But I cannot get it to work. Consider the following:

    $pdf = PDF::loadView('modules.efapreports.pdf.invoice', [
        'invoiceData'   => $this->collection,
        'organization'  => $organization,
        'invoiceNumber' => $this->formFields['invoice_number'],
        'invoiceDate'   => $this->formFields['invoice_date'],
        'dueDate'       => $this->formFields['due_date'],
        'payementTerms' => $this->formFields['payment_terms'],
        'gst'           => 1.05,
    ]);

    $pdf->save(storage_path(
        'efapinvoices/' . $this->getPath() .'/'. $this->getFileName() . $this->getExtension()
    ));

    $pdf->download(storage_path(
        'efapinvoices/' . $this->getPath() .'/'. $this->getFileName() . $this->getExtension()
    ));

This saves it, perfectly, but does not download it. Do I have to load the pdf file?

2
  • based on the documentation.. you need to "return" it.. Commented Sep 1, 2018 at 4:21
  • Just a note on the side: It would make sense to store the storage path in an own variable. Not only to save code but also to avoid very minor and hard to debug errors. Commented Sep 1, 2018 at 16:45

2 Answers 2

1
return PDF::loadView('modules.efapreports.pdf.invoice', [
        'invoiceData'   => $this->collection,
        'organization'  => $organization,
        'invoiceNumber' => $this->formFields['invoice_number'],
        'invoiceDate'   => $this->formFields['invoice_date'],
        'dueDate'       => $this->formFields['due_date'],
        'payementTerms' => $this->formFields['payment_terms'],
        'gst'           => 1.05,
    ])->download();
Sign up to request clarification or add additional context in comments.

Comments

0

you can use package dompdf to solve the problem related to pdf. https://packagist.org/packages/dompdf/dompdf

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.