Git Product home page Git Product logo

Comments (35)

amirakhalifa avatar amirakhalifa commented on June 14, 2024 3

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.

CoreFloDev avatar CoreFloDev commented on June 14, 2024 1

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.

CoreFloDev avatar CoreFloDev commented on June 14, 2024

the good solution is to use the static version of wkhtmltopdf like here #3

from knpsnappybundle.

nicktsarev avatar nicktsarev commented on June 14, 2024

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:

  1. Post the innerHTML to the server -> done
  2. Write a temporary HTML file with the posted data (file:write_file) -> done
  3. Convert this file to PDF using the command line WKHTMLTOPDF (os:cmd) -> fail
  4. Read and store the PDF file content to a variable (file:read_file) -> fail
  5. Delete the temporary HTML and PDF files (file:delete) ->fail
  6. 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.

Squazic avatar Squazic commented on June 14, 2024

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.

madal avatar madal commented on June 14, 2024

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.

pilot avatar pilot commented on June 14, 2024

OS windows?

and you have installed and worked version of wkhtmltopdf?

from knpsnappybundle.

madal avatar madal commented on June 14, 2024

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.

madal avatar madal commented on June 14, 2024

I just followed the instructions here:
https://github.com/KnpLabs/KnpSnappyBundle

from knpsnappybundle.

pilot avatar pilot commented on June 14, 2024

man ask again you have installed and worked wkhtmltopdf?

from knpsnappybundle.

madal avatar madal commented on June 14, 2024

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.

pilot avatar pilot commented on June 14, 2024

read this

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.

madal avatar madal commented on June 14, 2024

thanks, i will read it :)

from knpsnappybundle.

madal avatar madal commented on June 14, 2024

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.

pilot avatar pilot commented on June 14, 2024

You need install it on your system, and put path to the snappy config where snappy can find it

from knpsnappybundle.

madal avatar madal commented on June 14, 2024

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.

madal avatar madal commented on June 14, 2024

would you give me an example or .. ?

from knpsnappybundle.

pilot avatar pilot commented on June 14, 2024

http://code.google.com/p/wkhtmltopdf/wiki/compilation#Windows

from knpsnappybundle.

madal avatar madal commented on June 14, 2024

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.

madal avatar madal commented on June 14, 2024

I did download MinGW and start the program, now what i have to do ?

from knpsnappybundle.

inoryy avatar inoryy commented on June 14, 2024

@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.

DHorchler avatar DHorchler commented on June 14, 2024

I followed the instructions above and it still does not work on Windows7.
Anybody got it working on any windows flavour?

from knpsnappybundle.

inoryy avatar inoryy commented on June 14, 2024

@2manypeople above setup is what works on my Windows 7 x64.

from knpsnappybundle.

DHorchler avatar DHorchler commented on June 14, 2024

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.

docteurklein avatar docteurklein commented on June 14, 2024

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.

inoryy avatar inoryy commented on June 14, 2024

@docteurklein absolute path on windows won't work because of spaces and () in the path - "Program Files (x86)" breaks

from knpsnappybundle.

docteurklein avatar docteurklein commented on June 14, 2024

where would this break ?

from knpsnappybundle.

inoryy avatar inoryy commented on June 14, 2024

@docteurklein when snappy runs C:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe --lowquality "http://www.google.fr" "testfile.pdf"

from knpsnappybundle.

vsaraf avatar vsaraf commented on June 14, 2024

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.

Geczy avatar Geczy commented on June 14, 2024

Yep space in the file path will return this error. Solved by moving to c:\

from knpsnappybundle.

kelu95 avatar kelu95 commented on June 14, 2024

on windows you need to execute wkhtmltopdf as admin

from knpsnappybundle.

kelu95 avatar kelu95 commented on June 14, 2024

process for windows 7, that work for me :

  • install wkhtmltopdf
  • add wkhtmltopdf to your path enviroment
  • also restart server :)

from knpsnappybundle.

kiranps11 avatar kiranps11 commented on June 14, 2024

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.

elvis2 avatar elvis2 commented on June 14, 2024

@CoreFloDev, Thanks! That worked for me.

from knpsnappybundle.

amadohin avatar amadohin commented on June 14, 2024

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)

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.