Comments (15)
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.
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.
Thank you @atulmy your solution worked for me
from knpsnappybundle.
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.
@atulmy, Thanks it work!
from knpsnappybundle.
@atulmy Thanks !
from knpsnappybundle.
Have you tried with C:/wkhtmltopdf/wkhtmltopdf.exe
in the "binary" parameter ?
from knpsnappybundle.
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.
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.
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.
@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.
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.
you have to check the api, I don't remember if it's possible.
from knpsnappybundle.
you can also take advantage of symfony enviroments and compile a different container based on ENV variables (and arch)
from knpsnappybundle.
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)
- User deprecations in log HOT 4
- Most of options not working HOT 1
- PDF is generated, but message saying format is wrong. HOT 4
- Header and Footer are not displayed HOT 1
- wkhtmltopdf does not support es6 HOT 3
- Warning: Blocked access to file HOT 1
- You must define a binary prior to conversion HOT 4
- Symfony 5 + knp_snappy - failed to load and blocked access errors HOT 9
- Critical CVE in snappy HOT 2
- Symfony 6 + Webpack encore. Css bootstrap not load when export to pdf HOT 9
- Exit with code 1 due to network error: SslHandshakeFailedError (prod env) HOT 4
- JS present inside the twig file not executing HOT 1
- How to use it in cpanel? HOT 1
- Error Installation HOT 2
- wkhtmltopdf has been archived since Jan 2, 2023 HOT 1
- Page Number and Page Header HOT 2
- Version 1.9 is not compatible with Symfony 7.0 HOT 2
- Crash on a too long filePath HOT 1
- impossible to copy content in prod environment HOT 5
- Provide support for filenames with special characters. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knpsnappybundle.