Git Product home page Git Product logo

Comments (15)

bajalovic avatar bajalovic commented on June 14, 2024 3

Hi @btit , I had the same problem and just solved it. The problem is with the path to the pdf binary. Finally when I put path inside escaped double quotes, I fixed the problem.

binary: "\"C:/Program Files (x86)/wkhtmltopdf/wkhtmltopdf.exe\""

Let me know if this works for you.

from knpsnappybundle.

atulmy avatar atulmy commented on June 14, 2024 1

This worked for me:

knp_snappy:
    pdf:
        enabled:    true
        binary:     "\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe\""
        options:    []
    image:
        enabled:    true
        binary:     "\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe\""
        options:    []

from knpsnappybundle.

sonnylloyd avatar sonnylloyd commented on June 14, 2024 1

Thank you @atulmy your solution worked for me

from knpsnappybundle.

atulmy avatar atulmy commented on June 14, 2024 1

@sonnylloyd

You can even move it inside your '/project/app/Resources/native/' directory if wkhtmltopdf is not shared between different projects and use it in this way (with few helpful PDF settings):

knp_snappy:
    pdf:
        enabled: true
        binary: "%kernel.root_dir%/Resources/native/windows/wkhtmltopdf/bin/wkhtmltopdf.exe" 
        #binary: "%kernel.root_dir%/Resources/native/linux/wkhtmltopdf/bin/wkhtmltopdf"
        options:
            lowquality: false
            dpi: 300
            orientation: portrait
            grayscale: true

from knpsnappybundle.

dogrocker avatar dogrocker commented on June 14, 2024 1

@atulmy, Thanks it work!

from knpsnappybundle.

leylaJudy avatar leylaJudy commented on June 14, 2024 1

@atulmy Thanks !

from knpsnappybundle.

cbeyer avatar cbeyer commented on June 14, 2024

Have you tried with C:/wkhtmltopdf/wkhtmltopdf.exe in the "binary" parameter ?

from knpsnappybundle.

docteurklein avatar docteurklein commented on June 14, 2024

knowing the number of problems with windows / paths, I'm wondering if it wouldn't be good to make a special "smart" wrapper that tries to find the binary and configure it correctly.

from knpsnappybundle.

walidzardoum avatar walidzardoum commented on June 14, 2024

i have the same problem as you and finally it wokrs for me .
1/ i have installed wkhtmltopdf from windows installer here http://code.google.com/p/wkhtmltopdf/downloads/detail?name=wkhtmltopdf-0.9.9-installer.exe&can=2&q=
2/ and then i have added wkhtmltopdf in my path enviroment so it would be accessible directly :
My snappy config looks like this:

knp_snappy:
pdf:
enabled: true
binary: wkhtmltopdf
options: []
image:
enabled: true
binary: wkhtmltoimage
options: []
PS : this step can be ignored because at this stage i still have the same error : stderr: "'wkhtmltopdf' is not recognized as an internal or external command,

3/ The best solution is to copy your wkhtmltopdf (which contains the wkhtmltopdf.exe and some .dll files ) installation directory to you C:\wamp\www\Project\web directory
then when you call the generate method from your controller he find this command installed

i wish if this idea help you .

from knpsnappybundle.

tblancog avatar tblancog commented on June 14, 2024

I been trying to set this in knp_config.yml this so i can work with either with linux or Windows

knp_snappy:
    linux:
        enabled:    true
        binary:     %kernel.root_dir%/../bin/wkhtmltox/bin/wkhtmltopdf
        options:    []
    win:
        enabled:    true
        binary:     %kernel.root_dir%/../bin/wkhtmltox/bin/wkhtmltopdf.exe
        options:    []

So i can call the service like this..

$this->get("knp_snappy.win")->....

But had no luck, it says unrecognized options "linux" and "windows".

from knpsnappybundle.

docteurklein avatar docteurklein commented on June 14, 2024

@tblanco82 yeah, it doesn't work like that.

the only options you have are "image" or "pdf".
there is no such option as "linux" or "windows".
We don't detect platform, you have to configure it by hand, each platform/deploy being different.

from knpsnappybundle.

tblancog avatar tblancog commented on June 14, 2024

Thanks @docteurklein,
I already detected user agent OS, now i gotta change binary parameter.
Would it be possible to change this binary parameter doing something like this?

$this->get("knp_snappy.pdf")->setBinary("path/to/wkhtmltopdf.exe");

from knpsnappybundle.

docteurklein avatar docteurklein commented on June 14, 2024

you have to check the api, I don't remember if it's possible.

from knpsnappybundle.

docteurklein avatar docteurklein commented on June 14, 2024

you can also take advantage of symfony enviroments and compile a different container based on ENV variables (and arch)

from knpsnappybundle.

akovalyov avatar akovalyov commented on June 14, 2024

Just for reference, for windows there is also https://github.com/wemersonjanuario/wkhtmltopdf-windows so you can use composer and wkhtmltopdf on windows :)

from knpsnappybundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.