2011-08-19 123 views
0

我使用FPDF創建發票的PDF。空白PDF生成

然後,我將其添加爲電子郵件附件。

所有這些似乎對我來說都很好,在我的Mac上,但Windows系統上的用戶似乎正在獲取一個空白的PDF,沒有任何信息。

PHP調用附件的電子郵件

$EMAIL = $confirmation_customer_email_from; 
$EMAIL_NAME = $confirmation_customer_email_from_name; 
$mail = new PHPMailer(); 

require_once('giftaid.php'); 
$mail->AddAttachment($name, 'giftaid.pdf'); 

require_once('emails/mail.customer.invoice.php'); 
if (!$mail->Send()){ 
    echo 'Mailer error: ' . $mail->ErrorInfo; 
} 

unlink($name); 

giftaid.php

require('fpdf/fpdf.php'); 
$image1 = "../images_site/logo.gif"; 

$pdf= new FPDF(); 
$pdf->AddPage(); 
$pdf->SetMargins(1,1,1,1); 
$pdf->cell(40, 40, $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 33.78), 0, 0, 'L', false); 
$pdf->SetFont('Helvetica','B',30); 
$pdf->cell(150,10,'Gift Aid Declaration',0,0,'R',0); 
$pdf->line(102, 20, 199, 20); 

$m=microtime(true); 
$name = 'temp/'.$m.'.pdf'; 

$pdf->Output($name, 'F'); 

的PDF看起來在我的Mac罰款,使用Preview,但只有dispolays在Windows徽標圖像在Adobe打開時雜技演員。

有誰知道這個問題可能是什麼?

編輯:這也是在Adobe Reader空白的Mac

+0

'需要( 'FPDF/fpdf.php');'但談到'tcpdf' ......這怎麼可能? – k102

+0

哎呦,應該是FPDF。現在改變了問題。 – user896428

+0

你嘗試過不同的圖像嗎?你可以試試JPG圖像嗎? –

回答

1

正如評論,這是由於所使用的命令的順序。您不能在setFont()之前使用setCell()

1

請勿使用圖像作爲單元格內容。

$pdf->cell(40, 40, $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 33.78), 0, 0, 'L', false); 

而是使用

$pdf->cell(40, 40, "", 0, 0, 'L', false); 
$pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 33.78); 

,以獲得相同的結果