1

He pasado un código de desarrollo a produccion y al momento de pasarlo a linux he intentar generar el pdf que estoy generando sin problemas en local, me arroja un error en el servidor: El error hace referencia a un status 127:

The exit status code '127' says something went wrong: stderr: 
"/home/developer/webapps/myapp/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: 
error while loading shared libraries: libXrender.so.1: cannot open shared object file: 
No such file or directory " stdout: 
"" command: /home/developer/webapps/myapp/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 
--lowquality --keep-relative-links --enable-local-file-access 
'/tmp/knp_snappy63b385fdab4f15.46095990.html' '/tmp/knp_snappy63b385fdab5863.80197603.pdf'.

y tengo mi configuracion en snappy.php de esta forma:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Snappy PDF / Image Configuration
    |--------------------------------------------------------------------------
    |
    | This option contains settings for PDF generation.
    |
    | Enabled:
    |    
    |    Whether to load PDF / Image generation.
    |
    | Binary:
    |    
    |    The file path of the wkhtmltopdf / wkhtmltoimage executable.
    |
    | Timout:
    |    
    |    The amount of time to wait (in seconds) before PDF / Image generation is stopped.
    |    Setting this to false disables the timeout (unlimited processing time).
    |
    | Options:
    |
    |    The wkhtmltopdf command options. These are passed directly to wkhtmltopdf.
    |    See https://wkhtmltopdf.org/usage/wkhtmltopdf.txt for all options.
    |
    | Env:
    |
    |    The environment variables to set while running the wkhtmltopdf process.
    |
    */
    
    'pdf' => [
        'enabled' => true,
        'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'),
        //'binary'  => '/usr/local/bin/wkhtmltopdf',
        //'binary' => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf"',
        'timeout' => false,
        'options' => [
            'enable-local-file-access' => true,
            'keep-relative-links' => true,
        ],
        'env'     => [],
    ],
    
    'image' => [
        'enabled' => true,
        //'binary'  => env('WKHTML_IMG_BINARY', '/usr/local/bin/wkhtmltoimage'),
        'binary'  => base_path('vendor/h4cc/wkhtmltoimage-amd64/bin/wkhtmltoimage-amd64'),
        'timeout' => false,
        'options' => [],
        'env'     => [],
    ],

];

Alguna idea o sugerencia sobre como resolver este problema...

Utilizo Laravel 8

1 respuesta 1

1

Bueno la solucion a este problema es algosencillo, en el archivo publicado de snappy.php ubicado en config/snappy.php hay que descomentar la linea para linux y comentar la linea para windows.

//'binary'  => env('WKHTML_PDF_BINARY', '/usr/local/bin/wkhtmltopdf'),
'binary' => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf"',

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.