Comments (35)
I have the same problem ! the html file is created in the temp directory but not the pdf !
I added twkhtmltopdf in my path enviroment!
can you help me plzz
from knpsnappybundle.
Hi, i've got the same error and I found a solution.
First, install xvfb (sudo apt-get install xvfb)
Next, change the configuration of the bundle in app/config/config.yml by :
knp_snappy: pdf: enabled: true binary: xvfb-run wkhtmltopdf options: [] image: enabled: true binary: xvfb-run wkhtmltopdf options: []
I found this solution here http://stackoverflow.com/questions/9910975/pdf2html-in-php-convert-untilities-scripts-examples-demos/9924154#9924154
from knpsnappybundle.
the good solution is to use the static version of wkhtmltopdf like here #3
from knpsnappybundle.
Thanx for answer. I was read article at stackoverflow and issues at github and tried to do it before create a new issue here, but I'm still having a error.
The workflow for wkhtmltopdf looks like:
- Post the innerHTML to the server -> done
- Write a temporary HTML file with the posted data (file:write_file) -> done
- Convert this file to PDF using the command line WKHTMLTOPDF (os:cmd) -> fail
- Read and store the PDF file content to a variable (file:read_file) -> fail
- Delete the temporary HTML and PDF files (file:delete) ->fail
- Send back the final document to the client using the ‘application/pdf’ content type header -> fail
On my opinion, the wkhtmltopdf works, but works only before third step
from knpsnappybundle.
Did you try making sure the config file points to the correct wkhtmltopdf binary? I had to fix my path to get it to work.
from knpsnappybundle.
Hi,
I am using KnpSnappyBundle and i am getting this error:
public function saveInvoiceAction()
{
$session = $this->getRequest()->getSession();
$session->start();
$profile = $session->get('profile');
$invoice = $session->get('invoice');
$html = $this->renderView('InvFrontendBundle:Default:preview.html.twig', array('invoice' => $invoice, 'profile'=>$profile));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="tralala.pdf"'
)
);
}
ERROR:
The file 'C:\Users\madal\AppData\Local\Temp\knp_snappy502dc162a018c4.84540823.pdf' was not created (command: /usr/local/bin/wkhtmltopdf --lowquality "C:\Users\madal\AppData\Local\Temp\knp_snappy502dc1629fe996.73531235.html" "C:\Users\madal\AppData\Local\Temp\knp_snappy502dc162a018c4.84540823.pdf").
Can somebody help me please ?
from knpsnappybundle.
OS windows?
and you have installed and worked version of wkhtmltopdf?
from knpsnappybundle.
Even i did made it simpler:
$html = trim($this->renderView('InvFrontendBundle:Default:prev.html.twig', array()));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="tmp/file.pdf"'
)
);
and nothing again! :(
from knpsnappybundle.
I just followed the instructions here:
https://github.com/KnpLabs/KnpSnappyBundle
from knpsnappybundle.
man ask again you have installed and worked wkhtmltopdf?
from knpsnappybundle.
I don't think so. In the instructions in this page instalation of wkhtmltopdf is not included.
but probably they do it automaticaly or ... i don't know.
from knpsnappybundle.
and configuration section https://github.com/KnpLabs/KnpSnappyBundle#configuration
You should have http://code.google.com/p/wkhtmltopdf/ before you can use Snappy
from knpsnappybundle.
thanks, i will read it :)
from knpsnappybundle.
ok, i see, but there are no instructions how to install that in Symfony 2. I am beginner in this and i don't know what to do.
from knpsnappybundle.
You need install it on your system, and put path to the snappy config where snappy can find it
from knpsnappybundle.
I did download this: wkhtmltopdf-0.9.9-installer and i did install this, but nothing happen.
the instalation is in C:\Program Files (x86)\wkhtmltopdf
and the path that i have to create in config.yml should be something like
knp_snappy:
pdf:
enabled: true
binary: C:\Program Files (x86)\wkhtmltopdf
options: []
???
from knpsnappybundle.
would you give me an example or .. ?
from knpsnappybundle.
http://code.google.com/p/wkhtmltopdf/wiki/compilation#Windows
from knpsnappybundle.
ok, if i install my application on the server do i need to do all this crap with C++ and to install wkhtmltopdf and etc ?
The server is Linux based and probably they have everything we need to make this pdf convert to work ??
from knpsnappybundle.
I did download MinGW and start the program, now what i have to do ?
from knpsnappybundle.
@madal only way to get this to work on windows is to add wkhtmltopdf in your path enviroment so it would be accessible directly with wkhtmltopdf
.
My snappy config looks like this:
knp_snappy:
pdf:
enabled: true
binary: wkhtmltopdf
options: []
image:
enabled: true
binary: wkhtmltoimage
options: []
P.S. and yes, you'll need to install "all this crap" on server too.
from knpsnappybundle.
I followed the instructions above and it still does not work on Windows7.
Anybody got it working on any windows flavour?
from knpsnappybundle.
@2manypeople above setup is what works on my Windows 7 x64.
from knpsnappybundle.
Thanks, @Inori .
I keep getting
The file 'testfile.pdf' was not created (command: wkhtmltopdf --lowquality "http://www.google.fr" "testfile.pdf"
The funny thing about this is that the same command works fine on the command line.
Any idea?
from knpsnappybundle.
try to run this command in the same environment than your web server.
On systems like ubuntu, you could use:
su www-data
/usr/local/bin/wkhtmltopdf --lowquality "http://www.google.fr" "testfile.pdf"
Also, you should configure snappy to have the absolute path to wkhtmltopdf binary, eg: /usr/local/bin/wkhtmltopdf
or smthg like that.
from knpsnappybundle.
@docteurklein absolute path on windows won't work because of spaces and () in the path - "Program Files (x86)" breaks
from knpsnappybundle.
where would this break ?
from knpsnappybundle.
@docteurklein when snappy runs C:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe --lowquality "http://www.google.fr" "testfile.pdf"
from knpsnappybundle.
I have a setup on redhat thats giving me issues. I am able to run from the command line and get the PDF but it does not work from the bundle. I am using this with Symfony2 on Apache. I had this issue on my MAC which had a MAMP installation and I was able to use the link http://oneqonea.blogspot.in/2012/04/why-does-wkhtmltopdf-work-via-terminal.html to solve the issue but I am unable to find anything that helps me get through this on redhat "The file .... was not created error". I tried using both the static versions 0.9 and 0.11. Any help?
from knpsnappybundle.
Yep space in the file path will return this error. Solved by moving to c:\
from knpsnappybundle.
on windows you need to execute wkhtmltopdf as admin
from knpsnappybundle.
process for windows 7, that work for me :
- install wkhtmltopdf
- add wkhtmltopdf to your path enviroment
- also restart server :)
from knpsnappybundle.
how to give the path for binary if i put my application in server ,for example server address is www.wellness.com and i put wkhtmltopdf in www.wellness.com/wkhtmltopdf what should i give to binary path
from knpsnappybundle.
@CoreFloDev, Thanks! That worked for me.
from knpsnappybundle.
process for windows 7, that work for me :
- install wkhtmltopdf
- add wkhtmltopdf to your path enviroment
- also restart server :)
It worked for me, in windows 10 with symfony 4.
Add to your .env
WKHTMLTOPDF_PATH=wkhtmltopdf
WKHTMLTOIMAGE_PATH=wkhtmltoimage
Thank's
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.