khernik
khernik

Reputation: 2091

Generating PDF - what do I need?

I'm trying to generate PDF in my symfony 2 application - what do I need to do that? Right now I downloaded through composer the following bundle:

https://github.com/KnpLabs/KnpSnappyBundle

But trying to generate pdf using it gives me an error:

The exit status code '126' says something went wrong:
stderr: "sh: /var/www/html/khernik/app/../web/files: is a directory
"
stdout: ""

I think the problem lies in the configuration - app/config/config.yml:

knp_snappy:
    pdf:
        enabled:    true
        binary:     %kernel.root_dir%/../web/files
        options:    []

The binary line...where should it point to? I've read it should be some executable file...does knp bundle provide it? I've also tried downloading the following bundle:

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

But it gives me the following composer error:

no matching package found

How can I solve this issue?

Thanks!

Upvotes: 1

Views: 942

Answers (2)

repincln
repincln

Reputation: 2049

Install wkhtmltopdf and then configure config.yml. Download wkhtmltopdf:

http://wkhtmltopdf.org/downloads.html

After that configure config.yml. Binary is path to the wkhtmltopdf.

knp_snappy:
    pdf:
        enabled:    true
        binary:     /usr/local/bin/wkhtmltopdf
        options:    []

Upvotes: 0

Alexey B.
Alexey B.

Reputation: 12033

Install wkhtmltopdf first and you will get a binary file then. After installation, you can run it to verify that installation is correct

wkhtmltopdf http://google.com google.pdf

after that set binary in KnpSnappyBundle settings. To get wkhtmltopdf binary path type in terminal

which wkhtmltopdf

Upvotes: 1

Related Questions