【发布时间】:2018-12-28 10:27:22
【问题描述】:
我是新来的,我一直在寻找有关此问题的答案,但我无法找到解决此问题的方法。
我的项目包含一个计算器,它能够保存结果并让用户根据需要将其导出为 PDF 文件。 现在,问题是,我想根据结果在 PDF 文件上展示图像:例如。如果结果是 M1,则显示链接到 M1 的图像,依此类推。 有没有办法做到这一点?
我正在使用 PHP、MYSQL 数据库来保存结果和输入,以及 fPDF。任何帮助将不胜感激。 谢谢。
function Header(){
global $first;
global $second;
global $userinput;
global $client;
global $project;
global $obs;
global $vao;
global $perfil;
global $valuep; //this is the final result that needs to be linked to an image
global $lastname;
global $firstname;
global $lastname;
global $email;
global $address;
global $country;
global $state;
global $phone;
global $date;
// Select Arial bold 15
$this->AddFont('Raleway-Regular','','Raleway-Regular.php');
$this->AddFont('Raleway-Bold','','Raleway-Bold.php');
$this->SetFont('Raleway-Regular','',10);
$this->SetFont('Raleway-Bold','',10);
$this->Cell(22 ,5,'Name: ' . $firstname, '' .$lastname,0,0);
$this->Cell(20 ,5,'Email: ' . $email,0,1);
$this->Cell(20 ,5,'Phone: ' . $phone,0,1);
$this->Cell(20 ,5,'Website: ' . $state,0,1);
$this->Image('headerimage.jpg',160,15,30);
$this->Cell(100,0,'',0,0);
$this->Ln(5);
$this->SetFont('Raleway-Regular','',10);
$this->SetFillColor(0,0,0);
$this->SetDrawColor(255,255,255);
$this->Cell(25 ,5,"Project Name: " . $project ,0,1);
$this->Cell(24.5,5,'Client: ' .$client,1,0);
$this->Cell(25,5,'Date: ' . $date,0,1);
//
$this->Cell(0 ,5,'',0,1);
//
$this->Cell(190,0.3,'','T',0,'',true);
$this->Cell(0 ,5,'',0,1);
$this->SetFont('Raleway-Bold','',12);
$this->Cell(85 ,5,'Inputs ',0,0);
$this->Cell(25 ,5,'Span Details ',0,1);
$this->Cell(0 ,5,'',0,1);
$this->SetFont('Raleway-Regular','',11);
$this->Cell(190,0.3,'','T',0,'',true);
$this->Cell(0 ,5,'',0,1);
$this->Cell(25 ,5,'Name of Span: ' . $vao,0,0);
$this->Cell(0 ,5,'',0,1);
$this->Cell(0 ,5,'',0,1);
$this->Cell(85 ,5,'Wind Action: ' .$perfil . '' . $userinput . ' kN/m2]',0,0);
$this->SetFont('Raleway-Regular','',11);
$this->Cell(30 ,5,'Height: ' . $first . ' m',0,0);
$this->Cell(30 ,5,'Width: ' . $second . ' m',0,1);
//
$this->Cell(0 ,5,'',0,1);
//
$this->Cell(190,0.3,'','T',0,'',true);
$this->Cell(0 ,5,'',0,1);
$this->SetFont('Raleway-Regular','',11);
$this->SetFont('Raleway-Bold','',12);
$this->Cell(25 ,5,'Solution ',0,1);
$this->SetFont('Raleway-Regular','',11);
$this->Cell(0 ,5,'',0,1);
$this->Cell(190,0.3,'','T',0,'',true);
$this->Cell(0 ,5,'',0,1);
$this->Cell(25 ,5,'Final result: ' . $valuep,0,1); //image here next to the text
//
$this->Cell(0 ,5,'',0,1);
//
$this->Cell(0 ,5,'',0,1);
$this->Cell(0 ,5,'',0,1);
$this->Cell(0 ,5,'',0,1);
$this->SetFont('Raleway-Bold','',12);
$this->Cell(25 ,5,'Observations: ',0,1);
$this->SetFillColor(255,255,255);
}
function Footer(){
// Go to 1.5 cm from bottom
$this->SetY(-15);
// Select Arial italic 8
$this->SetFont('Raleway-Bold','',5);
// Print centered page number
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
$this->Cell(25,5,"Vestibulum placerat lorem venenatis nulla tempor maximus a ut elit.",0,0,'R');
} }
$pdf = new PDF('P','mm','A4'); $pdf->AliasNbPages('{pages}');
$pdf->SetAutoPageBreak(true,5); $pdf->AddPage();
$pdf->SetFont('Raleway-Regular','',10); $text=str_repeat('' .$obs,1); $pdf->Write(5,$text); $pdf->SetDrawColor(255,255,255);
$pdf->Output();
【问题讨论】:
-
对不起,我没有明白这一点。你指的是哪个结果?您能否详细说明您的预期输出是什么?如果需要,您甚至可以使用视觉辅助工具。
-
我还不能上传图片,所以我必须把它发到imgur@模糊了剧透。
-
好的。如果您无法上传图片,请以这样的方式格式化您的描述,以便向我们展示您的预期输出,以便我们清楚您实际需要什么帮助。