0

I am trying to use Snappy PDF from barrvdh but I'm getting an error.

My code is as below

 public function test_pdf($invoice_id)
{
    $invoices = InvoiceHeader::where('id', $invoice_id)->first();
    $pdf = PDF::loadView('billing.invoice.test', ['invoice' => $invoices]);
    return $pdf->download('invoice'.$invoices->id.'.pdf');
}

And my error is as below:

ErrorException in PDFController.php line 28: Missing argument 1 for App\Http\Controllers\PDFController::test_pdf()

w3spi
  • 4,380
  • 9
  • 47
  • 80
edmond
  • 119
  • 1
  • 4
  • 17

1 Answers1

0

First issue, you missed $invoice_id while calling test_pdf function

And for the second issue :

With your terminal, type this :

cd path/to/your/project
php artisan cache:clear
chmod -R 777 /var/www/html/bootstrap/cache/services.php
composer dump-autoload
w3spi
  • 4,380
  • 9
  • 47
  • 80
  • now i get this error The exit status code '127' says something went wrong: stderr: "sh: 1: /usr/local/bin/wkhtmltopdf: not found – edmond Aug 01 '16 at 21:55
  • Look here : https://stackoverflow.com/questions/5035601/error-running-wkhtmltopdf-error-while-loading-shared-libraries – w3spi Aug 01 '16 at 21:57
  • i followed steps on there but I'm still getting the error – edmond Aug 01 '16 at 22:01
  • the this is that its not finding the file. and i have moved the file to the required path and yet its not working, i don't know what I'm doing wrong and I'm not reinstalling the whole development environment – edmond Aug 01 '16 at 22:06
  • I have a new error now The exit status code '134' says something went wrong: stderr: "QXcbConnection: Could not connect to display Aborted " stdout: "" command: /usr/local/bin/wkhtmltopdf --lowquality '/tmp/knp_snappy579fcbbab48fb5.37600980.html' '/tmp/knp_snappy579fcbbab49731.67956603.pdf'. – edmond Aug 01 '16 at 22:24