Pogledajte određenu poruku
Staro 10. 08. 2012.   #26
slavkan
profesionalac
Professional
 
Datum učlanjenja: 29.08.2010
Poruke: 201
Hvala: 10
640 "Hvala" u 14 poruka
slavkan is on a distinguished roadslavkan is on a distinguished roadslavkan is on a distinguished roadslavkan is on a distinguished roadslavkan is on a distinguished roadslavkan is on a distinguished road
Default

Da li se mogu ova setovanja hedera za csv fajl iskoristiti i za pdf. Ovaj skript radi ali slova sa kvakicama takodje ne prolaze.
PHP kôd:
<?php
define
('FPDF_FONTPATH','./fpdf/font/');
require_once(
'fpdf.php');
include (
'include/config.php');


class 
PDF extends FPDF
{
    
//Load 
    
function LoadData($file)
    {
        
//Linije
        
$lines=file($file);
        
$data=array();
        foreach(
$lines as $line)
            
$data[]=explode(';',chop($line));
        return 
$data;
    }
    function 
FancyTable($header,$data)
    {
        
//Boja,font,
        
$this->SetFillColor(255,0,0);
        
$this->SetTextColor(255);
        
$this->SetDrawColor(128,0,0);
        
$this->SetLineWidth(.3);
        
$this->SetFont('','B');
        
//Heder
        
$w=array(20,30,55,25,25,25);
        for(
$i=0;$i<count($header);$i++)
            
$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
        
$this->Ln();
        
//Setovanje boje i fonta
        
$this->SetFillColor(224,235,255);
        
$this->SetTextColor(0);
        
$this->SetFont('');
        
//Data
        
$fill=false;
        foreach(
$data as $row)
        {
        
            
$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
            
$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
            
$this->Cell($w[2],6,$row[2],'LR',0,'L',$fill);
            
$this->Cell($w[3],6,$row[3],'LR',0,'C',$fill);
            
$this->Cell($w[4],6,number_format($row[4]),'LR',0,'R',$fill);
            
$this->Cell($w[5],6,number_format($row[5]),'LR',0,'R',$fill);
            
$this->Ln();
            
$fill=!$fill;
        }
        
$this->Cell(array_sum($w),0,'','T');
    }
}
$pdf=new PDF();
$header=array('Ime','Prezime','Br. kancelarije','Lokal','Dekt','VPN');
$strSQL "SELECT * FROM radnik";
$objQuery mysql_query($strSQL);
$resultData = array();
for (
$i=0;$i<mysql_num_rows($objQuery);$i++) {
    
$result mysql_fetch_array($objQuery);
    
array_push($resultData,$result);
}
$pdf->SetFont('Arial','',10);
$pdf->AddPage();
$pdf->Image('logo.jpg',80,8,33);
$pdf->Ln(35);
$pdf->FancyTable($header,$resultData);
$pdf->Output("MyPDF.pdf","F");
?>
<?php
echo'<html>
<head>
<title>PDF</title>
</head>
<body>Klikni <a href="MojPDF.pdf">OVDE</a> da kreiras PDF fajl
</body>
</html>'
;
?>
slavkan je offline   Odgovorite uz citat