Edinho Rodrigues
Edinho Rodrigues

Reputation: 366

Laravel Snappy PDF don't find the file path

On my PC laravel snappy pdf works perfectly, but when I send the files to the server it gives error when generating PDF. This is the error:
enter image description here

This is my config/snappy.php

    'pdf' => [
    'enabled' => true,
    'binary' => base_path('vendor\wemersonjanuario\wkhtmltopdf-windows\bin\64bit\wkhtmltopdf'),
    'timeout' => false,
    'options' => array(),
    'env'     => array(),
],

'image' => [
    'enabled' => true,
    'binary' => base_path('vendor\wemersonjanuario\wkhtmltopdf-windows\bin\64bit\wkhtmltoimage'),
    'timeout' => false,
    'options' => array(),
    'env'     => array(),
],

This is how I generate the PDF:

$filename = strtolower(str_replace(" ", "-", $user->id .'-'. $product->name)) . '-' . date('dmY') . '-' . date('Hisu') . '.pdf';
    $pdf = PDF::loadView('admin-customer.tag.pdf-view', $product)
                ->setOption('page-width', '100')
                ->setOption('page-height', '70.5')
                ->setOption('margin-top', 2)
                ->setOption('margin-bottom', 2)
                ->setOption('margin-left', 2)
                ->setOption('margin-right', 2)
                ->setOption('images', true)
                ->output();
    $disk = Storage::disk('pdf');
    if ($disk->put($filename, $pdf)) {
        return redirect('/cliente/etiquetas');
    }

This is my vendor folder:
enter image description here

I've searched several forums and still can't solve it. Can anyone help me?

Upvotes: 0

Views: 1295

Answers (1)

Edinho Rodrigues
Edinho Rodrigues

Reputation: 366

I found the problem and it was my lack of attention. The problem is that I use windows and the server was linux. I downloaded the files to linux and gave 777 permission on the files and it worked: https://github.com/wkhtmltopdf/wkhtmltopdf/releases/0.12.4

Upvotes: 1

Related Questions