WordPress的前端不显示由dompdf的PDF?

时间:2019-03-11 12:10:10

标签: php wordpress pdf dompdf

HTML到DOMPDF

这是我的php到dompdf的php代码。它可以在wordpress后端(管理员部分)中使用,但不适用于我的帐户页面(例如:/ my-account / view-pdf /)

index.php代码:

function dompdf_files_add(){
   ob_start();
   require_once plugin_dir_path(__FILE__) . 'dompdf/autoload.inc.php';
}
add_action('init','dompdf_files_add');

view_pdf.php代码:

use Dompdf\Dompdf; use Dompdf\Options;

if(isset($_POST['view'])){
    $qt_no=$_POST['qt_no'];
    $content = custom_invoice_generate($qt_no,"view");
}
$options = new Options();
$options->set('A4','potrait');
$options->set('enable_css_float',true);
$options->set('defaultFont', 'Helvetica');
$options->set('isHtml5ParserEnabled', true);
$options->set("isPhpEnabled", true);
$options->set('isRemoteEnabled', true);

$dompdf = new Dompdf();
$dompdf->loadHtml($content);
$dompdf->render();
ob_end_clean();
$dompdf->stream("sample_pdf",array("Attachment"=>0));
exit;

输出:

enter image description here

0 个答案:

没有答案