1

HTML/CSS/PHP ページを PDF に変換するための PHP スクリプトの作成に取り組んでいます。クラス domPDF に遭遇し、すべてのファイルをサーバーにアップロードしました。私はこれに頭を悩ませようとしており、このサンプルスクリプトを書いて、それが機能するかどうかを確認しました。スクリプトは次のとおりです。

ob_start() ;

require_once("dompdf_config.inc.php");

$file= file_get_contents('http://www.yahoo.com');

$dompdf = new DOMPDF();
$dompdf->load_html_file($file);
$dompdf->render();
$dompdf->stream("sample.pdf");

そして、私はこのエラーが発生しています:

"Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'Permission denied on <!DOCTYPE html> <html lang="en-US" class="y-fp-bg y-fp-pg-grad bkt701" style=""> <!-- m2 template --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Yahoo!</title> <meta http-equiv="X-UA-Compatible" content="chrome=1"> <meta name="description" content="Welcome to Yahoo!, the world's most visited home page. Quickly find what you're searching for, get in touch with friends and stay in-the-know with the latest news and information."> <meta name="keywords" content="yahoo, yahoo home page, yahoo homepage, yahoo search, yahoo mail, yahoo messenger, yahoo games, news, finance, sport, entertainment"> <script type="text/javascript"> //Roundtrip rtTop = Number(new Date()); document.documentElement.className += ' jsenabled'; </script> <script type="text/javascript"> (function () { //refresh check var d=document,c=";\ in /home/public_html/Sandbox/include/dompdf.cls.php on line 329"

4

2 に答える 2

4

私はあなたが使いたいと思う:

$dompdf->load_html($file);

それよりも

$dompdf->load_html_file($file);
于 2011-12-31T22:23:05.043 に答える
2

私は domPDF には詳しくありませんが、エラー メッセージと関数の名前から判断するload_html_file()と、ファイル名が必要だと思いますが、HTML ファイルの内容を指定しています。$dompdf->load_html_file( 'http://www.yahoo.com' )HTML 文字列をパラメーターとして受け入れる関数を試すか、見つけてください。

于 2011-12-31T22:20:58.817 に答える