2015-12-14 7 views
5

私はMySQL DBから動的ロードがあり、私のページURLはhttp://localhost/far/contractview?ID=137です。このページをPDFに変換しようとすると、いくつかのエラーが発生します。このページをPDFに変換するには、ボタンのクリックで何をすべきかわかりません。phpページをpdfに変換するID:

以下に私のコードを含めました。私はmpdfを使用しています。

<?php 
require("mpdf60/mpdf.php"); 
$mpdf=new mPDF('application/pdf','Letter-L','','',15,10,16,10,10,10);//A4 page in portrait for landscape add -L. 
$mpdf->debug = true; 
//$mpdf->allow_output_buffering = true; 
//$mpdf->SetHeader('|Your Header here|'); 
//$mpdf->setFooter('{PAGENO}');// Giving page number to your footer. 
$mpdf->useOnlyCoreFonts = true; // false is default 
$mpdf->SetDisplayMode('fullpage'); 
// Buffer the following html with PHP so we can store it to a variable later 
ob_start(); 
?> 
<?php 
//include "contractview.php"; 
include_once "users.php"; 
//This is your php page ?> 
<?php 
$html = ob_get_contents(); 
ob_end_clean(); 
// send the captured HTML from the output buffer to the mPDF class for processing 
$mpdf->WriteHTML($html); 
//$mpdf->SetProtection(array(), 'user', 'password'); uncomment to protect your pdf page with password. 
$mpdf->Output(); 
exit; 
?> 

ありがとうございます。

+0

あなたが取得している "いくつかのエラー" どのようなものですか?リンクチェックアウト – bIgBoY

+0

SCREAM:警告のためのエラー抑制が無視されました:include_once(contractview?ID = 137): – user2989676

+0

ここにphp-to-pdf.phpのコードが必要です。ご覧のとおり、ファイルではなくURLを含めるようにしています。 – bIgBoY

答えて

0
  1. 公式サイトからFPDFをダウンロードしてください。

http://www.fpdf.org/en/dl.php?v=17&f=zip

は、Webサーバーのフォルダにそれを2.put。

3. requireを使用してphpファイルと接続します。

作成-pdf.phpを

<?php 
require("fpdf17/fpdf.php"); 

$pdf=new FPDF(); 
//var_dump(get_class_methods($pdf)); 
$pdf->AddPage(); 

//------------------------ 
$pdf->Image("hello.jpg"); 
$pdf->SetFont("arial","B","20"); 

$pdf->Cell(0,20,"hello world",1,1,"C"); 
$pdf->SetFont("arial","I","10"); 

$pdf->Cell(0,30,"Second line Italic",1,1,"C"); 
$pdf->SetFont("arial","B","20"); 

$pdf->Cell(0,40,"thired line",1,1,"C"); 
$pdf->Output(); 
?> 

が、これはhttps://topdf.org/html-codehttp://php999.blogspot.in/2014/01/pdf-generation-in-php.html

関連する問題