2014-01-24 95 views
1

我工作動態使用PHP *的TCPDF/FPDI類生成PDF ..TCPDF本地工作,但不能上線

在本地開發(WAMP /本地主機)..事情已經工作的罰款。 。

現在我已經上傳的東西到LIVE服務器

..我什麼也沒得到,但在同一個文件一個空白頁。與相同的目錄結構..

然而,在真實環境中進行測試時..它不工作?

只是一個空白頁面,沒有錯誤..等等。

這裏是即時通訊目前使用的代碼..

(我試圖在構造函數和在HTML輸出的UTF-8編碼增加...... ??

代碼:

$live = false; 

$targetID = 122; 
$targetName = "Name"; 
$targetClient = "Client Name"; 

$targetAddress = "address"; 
$targetCity = "city"; 
$targetState = "State"; 
$targetZip = "40202"; 
$targetPhone = "xxx-555-1212"; 

$fileCreator = "xxxxx123"; 
$fileAuthor = "xxx"; 
$fileTitle = "Title"; 
$fileSubject = "Ssubject"; 

if($live){ 
$targetLogo = "/path/to/logo/images/targetLogo.jpg"; 
$sourcePDF = "/path/to/pdf/targetPDF.pdf"; 
}else{ 
$targetLogo = "images/targetLogo.jpg"; 
$sourcePDF = "targetPDF.pdf"; 
} 
$saveAsName = "DYNAMIC_BRANDING.pdf"; 

//client specific variables 
$clientName_color = '#FF0000'; 
$memberName_color = '#000000'; 
$clientAddress_color = '#000000'; 


//------------------[end project vars]---------------------// 



// just require TCPDF instead of FPDF 
define('FPDF_FONTPATH', 'tcpdf/fonts/'); 
//include FPDI & TCPDF class library file(s) 


if($live){ 
//ini_set('display_errors', '0'); 
//error_reporting(E_ALL | E_STRICT); 
//live 
require('/path/to/tcpdf.php'); 
require('/path/to/fpdi.php'); //make sure to include the _TPL file in directory or it throws error. 

}else{ 
ini_set('display_errors', '0'); 
error_reporting(E_ALL | E_STRICT); 
//local file path (WAMP server) 
require('tcpdf/tcpdf.php'); //<-- order matters here 
require('fpdi/fpdi.php'); //<-- order matters here 
} 


//Page width in PT: 595.275590551 
//Page height in PT: 841.88976378 

//Page width in MM (default): 210 
//Page height in MMK (default): 297 

//$measurementUnits = 'mm'; //[mm or pt] // not needed, used for measurement checking 

// initiate FPDI 
//http://www.tcpdf.org/doc/code/classTCPDF.html#a134232ae3ad1ec186ed45046f94b7755 
//$pdf = new FPDI(); 
//$pdf = new FPDI('P', 'pt', 'A4'); 
//$pdf = new FPDI('P', 'mm', 'A4'); //default 
$pdf = new FPDI('P', 'mm', 'A4', true, 'UTF-8', false); //default 

//mm to px converter: http://www.endmemo.com/sconvert/millimeterpixel.php 
//pt to px converter: http://www.endmemo.com/sconvert/pixelpoint.php 
//good for finding values when using image placement (pixel to xxx conversion 

$pdf->SetAutoPageBreak(TRUE, 0); //added to remove HUGE bottom margin 

//add project meta data/vars 
// set document information 
$pdf->SetCreator($fileCreator); 
$pdf->SetAuthor($fileAuthor); 
$pdf->SetTitle($fileTitle); 
$pdf->SetSubject($fileSubject); // displays where? 
$pdf->SetKeywords('XXX, XXX, Meeting, 2014, etc'); // meta-tags? meta-data? 


// add a page 
$pdf->AddPage(); 
// set the source file 
$pdf->setSourceFile($sourcePDF); 
// import page 1 
$tplIdx = $pdf->importPage(1); 
// use the imported page and place it at point 10,10 with a width of 210mm (width of A4) 
$pdf->useTemplate($tplIdx, -1, -1, 210, 297); //-1 to off set shadow test //units:mm 
//$pdf->useTemplate($tplIdx, -1, -1,0,0); 


//add 'footer/branding' data at bottom 

//position table at bottom 
$pdf->SetXY(12, 265); 
//set table font 
$pdf->SetFont('Arial', "", 9, true); 
//$pdf->SetFont('Helvetica', '', 9, true); 
//set table color 
$pdf->SetTextColor(0, 0, 0); //black 

//table html 
//add css for easier formatting/styling of overlay content 
$html ='<!-- EXAMPLE OF CSS STYLE --> 
<style> 
#overlay{ 
    width:523mm; 
    padding:0; 
    border:0;  
} 

.clientName{ 
    text-align:left; 
    color:'.$clientName_color.'; 
    font-size: 10.5pt; 
    font-weight:bold; 
    width:223; 
} 

.clientLogo{ 
    margin-left:auto; 
    margin-right:auto; 
    padding:0; 
    width:100; 
} 

.memberName{ 
    text-align:right; 
    font-weight:bold; 
    width:200; 
    color:'.$memberName_color.'; 
} 

.clientAddress{ 
    //font-weight:bold; 
    text-align:right; 
    width:200; 
    color:'.$clientAddress_color.'; 
} 

.clientCityState{ 
    //font-weight:bold; 
    text-align:right; 
    width:200; 
    color:'.$clientAddress_color.'; 
} 

.clientPhone{ 
    //font-weight:bold; 
    text-align:right; 
    width:200; 
    color:'.$clientAddress_color.'; 
} 
</style> 
<table cellspacing="0" cellpadding="0" border="0" width="523"> 
<tr> 
    <td rowspan="6" class="clientName">'.$targetClient.'</td> 
    <td rowspan="6" class="clientLogo"><center><img src="'.$targetLogo.'" height="80" width="90"></center></td>  
    <td class="memberName">'.$targetName.'</td>   
</tr> 
<tr> 
    <td class="clientAddress">'.$targetAddress.'</td> 
</tr> 
<tr> 
    <td class="clientCityState">'.$targetCity.', '.$targetState.'. '.$targetZip.'</td>  
</tr> 
<tr> 
    <td class="clientPhone">'.$targetPhone.'</td>  
</tr> 
</table>'; 

//echo($html); 
//render out/output the HTML table to pdf overlay (table) 
$pdf->writeHTML($html, true, false, true, false, ''); 

//add page number/count 
//position table at bottom 
$pdf->SetXY(12, 285); 
//set table font 
$pdf->SetFont('Helvetica', '', 9); 
//set table color 
$pdf->SetTextColor(0, 0, 0); //black 
$pdf->Write(10, 'Page: '.$pdf->getAliasNumPage().'/'.$pdf->getAliasNbPages(),'', false,'L',true,0, false, false,0,0,''); 
//$pdf->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); 

//output 
$pdf->Output($saveAsName, 'I'); 

只是一個空白/空WHITE每個測試現場時,頁面停留時間..

我缺少什麼或者做錯了嗎?

回答

0

固定:

幾件事情要記住:

1)不要有任何空格或空格您啓動OUPUT前

2)確保你有一個文件:fpdf_tpl.php在你的FPDI目錄..

(第二個人似乎是我最初的倒臺):)

相關問題