1

localhost/invoicenamedx.phpとに 2 つのファイルがありtemplate.php、次のような URL があります。

localhost/invoice/template.php?name=wawan

出力ページを PDF に変換するにはどうすればよいですか? 私が欲しいのは、アクセスx.phpして変換された を取得することtemplate.phpです。mpdf を使用してみましたが、うまくいきません。

ここにありx.phpます:

<?php
include("MPDF54/mpdf.php");

$mpdf=new mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0); 

$mpdf->SetDisplayMode('fullpage');

$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list

$mpdf->WriteHTML(file_get_contents('template.php?name=wawan'));

$mpdf->Output();
?>

これはtemplate.php次のとおりです。

<div> The name is :
<?php


echo $_GET[name];

?>
4

1 に答える 1

1

出力バッファリングを使用できます:

# Capture the output of the page:
ob_start();

$_GET['name'] = 'wawan';

require 'template.php';

$content = ob_get_contents();

ob_end_clean();

# Write the captured HTML to the PDF:
$mpdf->WriteHTML($content);
于 2012-12-12T03:44:37.857 に答える