Search code examples
laravelwkhtmltopdf

Laravel snappy pdf --viewport-size 1024x768 wkhtmltopdf windows OS not work


viewport-size, this command not working in windows OS

Here is my config from laravel snappy pdf config/snappy.php

'pdf' => [
    'enabled' => true,
    'binary'  => '"C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe --viewport-size 1024x768"',
    'timeout' => false,
    'options' => [],
    'env'     => [],
],

When I use above config, it shows an error like this:

The exit status code '1' says something went wrong: stderr: "'"C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe --viewport-size 1024x768"' is not recognized as an internal or external command, operable program or batch file. " stdout: "" command: "C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe --viewport-size 1024x768" --lowquality

Any solution of this case?


Solution

  • Try this. You have to install wkhtmltopdf for windows with composer.

    composer require wemersonjanuario/wkhtmltopdf-windows
    
    'pdf' => array(
        'enabled' => true,
        'binary' => base_path('vendor/wemersonjanuario/wkhtmltopdf-windows/bin/64bit/wkhtmltopdf.exe'),
        'timeout' => false,
        'options' => array(),
        'env'     => array(),
    ),
    'image' => array(
        'enabled' => true,
        'binary' => base_path('vendor/wemersonjanuario/wkhtmltopdf-windows/bin/64bit/wkhtmltoimage.exe'),
        'timeout' => false,
        'options' => array(),
        'env'     => array(),
    ),