我将助您翻译以下内容。这是一篇关于IT技术的文章。
我正在尝试从数据库中提取一些数据和图像并保存为PDF文件。我可以正常保存,但是图片无法显示。$ft1、$ft2和$ft3是数据库变量,它们存储了图片的名称。
以下是我的测试代码:
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');