2014-01-24 2 views
1

Я работаю на динамически генерировать PDF с помощью PHP * TCPDF/классы FPDI ..TCPDF работает локально, а не на линии

При разработке локально (WAMP/Localhost) .. вещи работают нормально. .

теперь, когда я загрузил вещи в реальном сервере .. я не получаю ничего, кроме пустой страницы на том же файлы .. с той же структурой каталогов ..

Однако при тестировании на реальных условиях .. он не работает?

Просто пустая страница, никаких ошибок .. и т.д.

здесь код Im в настоящее время, используя ..

(я пытался добавить в кодировке UTF-8 в конструкторе и в выводе HTML ... ??

код:

$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'); 

Просто пустой/пустой белый Page каждый раз при тестировании в прямом эфире ..

что я отсутствую или делаю неправильно?

ответ

0

исправлено:

пару вещей, чтобы помнить:

1.) не имеют каких-либо пробелов или пробелов перед началом Ouput

2.) убедитесь, что у вас есть файл: fpdf_tpl.php в ваш каталог FPDI.

(второй, казалось, был моим падением) :)

Смежные вопросы