douyoupingji7238 2015-05-25 09:10
浏览 25

DOMPDF Wordpress没有任何反应

I have a problem with DOMPDF integration into Wordpress.

Here are the steps done:

  1. Installed DOMPDF 0.6.1 into the themedir/dompdf/
  2. Created path /dompdf/lib/php-font-lib/classes where php lib is to be imported
  3. Imported the "FontLib" folder contents (version 0.4) into the /dompdf/lib/php-font-lib/classes

Here is the code:

    require_once(echo get_template_directory_uri()."/dompdf/dompdf_config.inc.php");

$html =
  '<html><body>'.
  '<p>Put your html here, or generate it with your favourite '.
  'templating system.</p>'.
  '</body></html>';

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream(echo get_template_directory_uri()."/dompdf/testpdf.pdf");

Outputs nothing, I have also tried stream("testpdf.pdf"); as the last line but no success.

Any ideas? Thank you.

  • 写回答

1条回答 默认 最新

  • doule6314 2015-06-19 01:45
    关注

    Try this

    include get_template_directory() . '/dompdf/dompdf_config.inc.php';
    
    $html =
      '<html><body>'.
      '<p>Put your html here, or generate it with your favourite '.
      'templating system.</p>'.
      '</body></html>';
    
    $dompdf = new DOMPDF();
    $dompdf->load_html( $html );
    $dompdf->render();
    file_put_contents( get_template_directory() . "/dompdf/testpdf.pdf");
    
    评论

报告相同问题?