2011-11-02 74 views
0

所以我使用FPDF(PHP)FPDF - 打印PDF被搞砸了根據計算機上

然而,當我們去打印這些文件似乎從我的計算機正確打印編碼的PDF文檔,但是當我從打印我的老闆筆記本電腦把事情搞砸了。

唯一的區別是他已經安裝了惠普設置,我沒有。

這裏是我的代碼也許在那裏錯了嗎?

<?php 
mysql_connect("localhost","DBUSER","DBPASS"); 
mysql_select_db("DB"); 
require('fpdf/fpdf.php'); 

class PDF extends FPDF 
{ 
// Page header 
    function Header() 
    { 
     // Logo 
     $this->Image('header.png',10,0,200); 
     // Arial bold 15 
     $this->SetFont('Arial','B',15); 
     // Move to the right 
     $this->Cell(80); 
     // Line break 
     $this->Ln(20); 
    } 

// Page footer 
    function Footer() 
    { 
    // Position at 1.5 cm from bottom 
    $this->SetY(-15); 

    //$this->Image('footer.png',0,200,'210%'); 
    // Arial italic 8 
    //$this->SetFont('Arial','I',8); 
    // Page number 
    //$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C'); 
    } 
} 

$pdf=new FPDF(); 

//Select the Products you want to show in your PDF file 
$arr = array($_GET['ids']); 
reset($arr); 
while (list(, $value) = each($arr)) { 

$result=mysql_query("SELECT customer.* FROM customer_detail as customer WHERE customer.customer_id IN ({$value})"); 
$number_of_customers = mysql_numrows($result); 



//For each row, add the field to the corresponding column 
while($row = mysql_fetch_array($result)) 
{ 
$pdf->AliasNbPages(); 
$pdf->AddPage(); 
    $name = ""; 
    $TradingName = ""; 
    $Street = ""; 
    $City = ""; 
    $state = ""; 


    $name = ucfirst($row["FirstName"])." ".ucfirst($row["LastName"]); 
    $TradingName = $row["TradingName"]; 
    $Street = $row["Street"]; 
    $City = $row["City"]; 
    $state = $row["State"]; 

    if($state == 1) 
    { 
    $states = "VIC"; 
    } 
    else if($state == 2) 
    { 
    $states = "NSW"; 
    } 
    else if($state == 3) 
    { 
    $states = "QLD"; 
    } 
    else if($state == 4) 
    { 
    $states = "WA"; 
    } 
    else if($state == 5) 
    { 
    $states = "TAS"; 
    } 
    else if($state == 6) 
    { 
    $states = "SA"; 
    } 
    else if($state == 7) 
    { 
    $states = "ACT"; 
    } 
    else if($state == 8) 
    { 
    $states = "NT"; 
    } 

    $PostCode = $row["PostCode"]; 

    $TradingName_code = $TradingName_code.$TradingName."\n"; 
    $Name_Code = $Name_code.$name."\n"; 
    $Address_code = $Address_Code.$Street."\n"; 
    $StateCityPostcode_code = $City." ".$states." ".$PostCode."\n"; 





//Create lines (boxes) for each ROW (Product) 
//If you don't use the following code, you don't create the lines separating each row 





// Instanciation of inherited class 
    $pdf->SetFont('Arial','B',12); 
    $pdf->Ln(60); 
    $pdf->SetXY(25,65); 
    $pdf->Cell(0,5,$TradingName,0,1); 
    $pdf->SetXY(25,70); 
    $pdf->Cell(0,5,$name,0,1); 
    $pdf->SetFont('Arial','',12); 
    $pdf->SetXY(25,75); 
    $pdf->Cell(0,5,$Street,0,1); 
    $pdf->SetXY(25,80); 
    $pdf->Cell(0,5,$StateCityPostcode_code,0,1); 
    $pdf->Ln(30); 
    $pdf->Cell(0,5,"Dear ". ucfirst($row['FirstName']),0,1); 
    $pdf->Ln(5); 
    $pdf->Write(5,'Thank you and welcome to the Company program.'); 
    $pdf->Ln(8); 
    $pdf->Write(5,'Please find enclosed your preliminary iNcard to access our Company program.'); 
    $pdf->Ln(8); 
    $pdf->Write(5,'An Company representative will contact you by telephone in the next couple of days to assist you in validating your iNcard. To allow us to complete your business listing and start promoting it to over 300,000 of our iNcard holders, the validation process is as follows:'); 
    $pdf->SetXY(25,170); 
    $pdf->Cell(0,5,"1. Your iNcard is activated over the phone and loaded with $1",0,1); 
    $pdf->SetXY(25,175); 
    $pdf->Cell(0,5,"2. An SMS confirmation is then sent to your mobile number",0,1); 
    $pdf->SetXY(25,180); 
    $pdf->Cell(0,5,"3. Once received, please run the $1.00 transaction through your EFTPOS terminal",0,1); 
    $pdf->SetXY(25,185); 
    $pdf->Cell(0,5,"4. You will then receive a follow up call to nominate a user name unique to your business",0,1); 
    $pdf->SetXY(25,190); 
    $pdf->Cell(0,5,"and to capture your business details",0,1); 
    $pdf->SetXY(25,195); 
    $pdf->Cell(0,5,"5. A password is then supplied to enable you to access your account activities ",0,1); 
    $pdf->SetXY(25,200); 
    $pdf->Cell(0,5,"via http://manage.URL.com.au ",0,1); 
    $pdf->Ln(8); 
    $pdf->Write(5,"Once again, welcome to the program and should you require any assistance or clarification on any of the above points please do not hesitate to contact us."); 
    $pdf->Ln(12); 
    $pdf->Cell(0,5,"Kind regards,",0,1); 
    $pdf->Cell(0,5,"Retail Support",0,1); 
    $pdf->Cell(0,5,"Comp Pty Ltd",0,1); 



} 
mysql_close(); 
} 

$pdf->Output(); 
?> 
+0

目前還不清楚你在這裏問什麼。你知道文件是否被髮送到打印機嗎?也是行$ pdf-> Output(); 推出一致的輸出? – jakx

+0

不確定 - 我們仍然需要手動下載pdf,並打印 – RussellHarrower

回答

0

我不認爲你的代碼有問題。它與不同計算機上的不同設置有關。您的老闆可能會有一些設置控制頁面佈局,因此與沒有這些設置的情況下打印頁面相比,打印的頁面看起來不同。