Php 使用FPDF在PDF中插入图像

Php 使用FPDF在PDF中插入图像,php,fpdf,Php,Fpdf,我想使用PHP创建PDF,为此我使用FPDF。现在我想在PDF顶部添加两个图像(一个在左角,一个在右角)。我正在为此使用以下代码 代码:- function Header () { $this->Image('logo.png',10,20,33,0,'','http://www.fpdf.org/'); $this->SetFont('Arial', 'B', 20); $this->SetFillColor(36, 96, 84); $this->SetTex

我想使用PHP创建PDF,为此我使用FPDF。现在我想在PDF顶部添加两个图像(一个在左角,一个在右角)。我正在为此使用以下代码

代码:-

function Header () {
$this->Image('logo.png',10,20,33,0,'','http://www.fpdf.org/');    
$this->SetFont('Arial', 'B', 20);
$this->SetFillColor(36, 96, 84);
$this->SetTextColor(28,134,238);
$this->Cell(0, 10, "Your Car Comparison Document", 0, 1, 'C', false);
$this->Cell(0, 5, "", 0, 1, 'C', false);
$this->Cell(0, 10, "Thanks for visiting CarConnect.", 0, 1, 'C', false);
$this->Cell(0, 5, "", 0, 1, 'C', false);
}

但是,当我添加图像代码时,浏览器上会显示404错误,否则它会正常工作。

HTTP url看起来不正确的图像url,请使用正确的图像url
'http://www.fpdf.org/logo.png“
图像
方法参数错误,请参见

//Image(string file [, float x [, float y [, float w [, float h [, string type [, mixed link]]]]]])


$this->Image('http://www.fpdf.org/logo.png',10,20,33,0); 

确保舒尔的img路径正确。您的脚本可能放在其他文件夹中并被包括在内。在这种情况下,让舒尔选择正确的道路。

我上周也做了同样的事情。但是一个注释:

404错误=未找到页面;你的形象或道路可能是错误的

我使用了以下代码,图像大小为20x10:

$imagenurl = "../imgs/incgaminglabs.png"; // in my case

// 1) left corner in coord x=1 and y=1
$pdf->Cell(0, 0, $pdf->Image($imagenurl, 1,1,20,10), 0, 0, 'C', false,'');

// 2) right corner in coord x=$pdf->GetX() - image width + 1 and y = $pdf->GetY() - image height + 1
$pdf->Cell(0, 0, $pdf->Image($imagenurl, $pdf->GetX()-20+1,$pdf->GetY()-10+1,20,10), 0, 0, 'C', false,'');

我希望这对你有用。尝试更改值。

在同一个文件夹中有一个图像(logo.png),我也放了一个完整的图像url,但我面临着同样的问题。
$pdf->Image('PATH/logo.png',10,3,50);