2
我試圖從數據庫和一些圖像保存一些PDF數據。我可以正常保存,但圖像不顯示。 $ ft1,$ ft2和$ ft3是具有圖像名稱的數據庫變量。TCPDF - 圖像沒有顯示
這裏是我的測試代碼:
require_once('../tcpdf/config/lang/bra.php');
require_once('../tcpdf/tcpdf.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 006');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
$html.= "<div><img src='../uploads/".$ft1."' width='200' height='400' /><br><br><img src='../uploads/".$ft2."' /><br><br><img src='../../uploads/".$ft3."' /></div>";
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->lastPage();
ob_clean();
$pdf->Output('../uploads/'.$norepeat.'_relatorio_'.$idcontrato.'_'.formatDataJustNumbers($_POST['datarelatorio']).'.pdf', 'F');
相對路徑?嘗試絕對,看看它是否有效。 – Orbling
不,它不是。 – MCP
其他需要注意的事項,可以從腳本中讀取圖像,安裝GD或IMagick,圖像受支持的類型等。通常,人們在HTML中使用雙引號。 – Orbling