Symfony Snappy - dosnt work on Virtualserver

417 views Asked by At

I wanted to use KnpSnappy for my project to convert html to pdf and I followed the instructions from https://github.com/KnpLabs/KnpSnappyBundle. At First I tried it locally and everything worked perfectly.

And than I wanted to upload it on my Virtualserver (with plesk). There I changed the binary path of wkhtmltopdf. Because I tested it on Windows before and my Server is running with ubuntu.

I also installed wkhtmltopdf over the ssh and I tried it via wkhtmltopdf --version. It works but when i try it in symfony the page doesn't load anymore, I get the exception ERR_TOO_MANY_REDIRECTS.

.env:

###> knplabs/knp-snappy-bundle ###
WKHTMLTOPDF_PATH=/usr/local/bin/wkhtmltopdf
WKHTMLTOIMAGE_PATH=/usr/local/bin/wkhtmltoimage
###< knplabs/knp-snappy-bundle ###

config/packages/knp_snappy.yaml:

knp_snappy:
    pdf:
        enabled:    true
        binary:     '%env(WKHTMLTOPDF_PATH)%'
        options:    
            enable-local-file-access: true
          
    image:
        enabled:    true
        binary:     '%env(WKHTMLTOIMAGE_PATH)%'
        options:    
            enable-local-file-access: true

So this is the current Situation, I hope someone can help me.

1

There are 1 answers

0
hous On

try with https://github.com/h4cc/wkhtmltopdf-amd64

and then in the config the path should be something like this:

knp_snappy:
    pdf:
        enabled:    true
        binary:     '%kernel.project_dir%/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'
        options:
            page-size: A4
            encoding: UTF-8
    image:
        enabled:    true
        binary:     '%kernel.project_dir%/vendor/h4cc/wkhtmltoimage-amd64/bin/wkhtmltoimage-amd64'
        options:    []

    process_timeout: 3