3

wkhtmltopdf sounds like an excellent solution...the problem is nothing happens on the exec

shell_exec("c:\wkhtmltopdf.exe","http://www.google.com google.pdf");

Am i doing anything wrong?

4

3 に答える 3

6

「公式」クラスを使用できますか?

http://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp

そうでない場合は、おそらく彼らがどのように物事を行ったかを覗いてみると、実装に役立つでしょう。

// Include WKPDF class.
require_once('wkhtmltopdf/wkhtmltopdf.php');

// Create PDF object.
$pdf = new WKPDF();
// Set PDF's HTML
$pdf->set_html('Hello <b>Mars<.b>!');
// Convert HTML to PDF
$pdf->render();
// Output PDF. The file name is suggested to the browser.
$pdf->output(WKPDF::$PDF_EMBEDDED, 'sample.pdf');

編集:

Github からの新しいリンク - https://github.com/mikehaertl/phpwkhtmltopdf

于 2010-08-13T16:38:51.433 に答える
0

wkhtmltopdf.exe CLASS_PATH変数へのパスを追加し、phpスクリプトで次のコードを使用します

passthru( "wkhtmltopdf www.gmail.com output.pdf"、$ err);

// PDFヘッダーを出力します('Content-type:application / pdf');

//これはdownloaded.pdfheader('Content-Disposition:attachment; filename = "output.pdf"');と呼ばれます。

// PDFソースはoriginal.pdfにありますreadfile('output.pdf');

私はこれがうまくいくことを願っています...

于 2010-09-02T09:08:57.613 に答える
0

shell_exec() は 1 つのパラメーターしか取りませんが、2 つ指定しています。代わりにこれを試してください:

shell_exec("c:\wkhtmltopdf.exe http://www.google.com google.pdf");

それで済むと思います。関数の使用を検討することもできexec()ます。

于 2010-08-13T10:11:04.193 に答える