tirenweb
tirenweb

Reputation: 31709

Trying to generate a pdf using Snappy (wkhtmltopdf wrapper)

I'm trying to generate a pdf using snappy through this code:

$snappy = new SnappyPdf;

$snappy->setExecutable('/usr/bin/wkhtmltopdf');

$snappy->save('http://www.google.com', '/tmp/jander.pdf');

In the apache log i find this:

Done Loading pages (1/6) [>
] 0% [======>
] 10% [==========>
] 18% [============>
] 20% [=============>
] 22% [===============>
] 25% [================>
] 28% [==================>
] 30% [===================>
] 33% [=====================>
] 35% [======================>
] 37% [=========================>
] 43% [===========================>
] 46% [============================================================] 100% Counting pages (2/6) [============================================================] Object 1 of 1 Resolving links (4/6) [============================================================] Object 1 of 1 Loading headers and footers (5/6) Printing pages (6/6) [> ] Preparing [============================================================] Page 1 of 1 Done

but the pdf is not generated.

Any idea?

Javier

Upvotes: 1

Views: 4450

Answers (2)

amitchhajer
amitchhajer

Reputation: 12830

use $snappy->generate

or

$snappy->generateFromHtml($htmlstring, 'path/to/save/file')

Upvotes: 1

joshden
joshden

Reputation: 798

I suggest you start by looking at the return value from $snappy->save(). According to the code, it will return true if the outputted PDF file is created and the file is not empty.

You might also want to check the output of $this->buildCommand($url, $path) on line 37 of the code. Try manually executing this code on your server.

Upvotes: 2

Related Questions