Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    239

    FPDF impaginazine immagini e testo

    Ciao,

    sto cercando disperatamente di creare un PDF con una colonna a dx per le immagini e il relativo testo a dx.

    Ho provato a fare così ma, mi stampa prima tutto il testo e poi tutte le immagini.

    Codice PHP:
    require('./fpdf/fpdf.php');
    require_once(
    "./_include/sql_class.php");

    class 
    PDF extends FPDF
    {
    //Page header
    function Header()
    {
        
    //Logo
        
    $this->Image('./pdf/imgs/virtual.png',10,8,33);
        
    $this->Ln(20);
            
    }

    function 
    content()
    {
    $sql=new sql;
    $sql->_select_db();
    $query=$sql->_query("select * from works") or die (mysql_error());
    while (
    $array=$sql->_fetch_array($query))
    {
        
    $this->SetFont('Arial','B',12);
        
    $this->Cell(75,6,'COMMITTENTE:',0,0,'R');
        
    $this->SetFont('Arial','',12);
    $this->Cell(100,6,$array['committente'],0,0,'L');
    $this->Ln(5);


        
    $this->SetFont('Arial','B',12);
        
    $this->Cell(75,6,'OGGETTO:',0,0,'R');
        
    $this->SetFont('Arial','',12);
        
    $this->MultiCell(100,5,$array['titolo']);
    //$this->Cell(50,55,$array['titolo'],0,0,'L'); 



              
    $this->SetFont('Arial','B',12);
    $this->Cell(75,6,'PERIODO:',0,0,'R');
    $this->SetFont('Arial','',12);
    $this->Cell(100,6,$array['periodo'],0,0,'L');

        
    $this->Ln(6);
            
    $this->SetFont('Arial','B',12);
        
        
    $this->SetFont('Arial','B',14);
        
    $x=$this->GetX()+71;

      
    $this->Ln(2);     
      
    $filename='.././_modules/works/text/long/work_'.$array['work_id'].'_long.txt';    
        
    $text_repla=implode("",file($filename));
        
    $tags=array('[B]','[/B]','

    '
    ,'</P>','[i]','[/i]','<span class=alto>','</span>');
        
    $repl=array('','','','','','','','');
        
    $text_repl=str_replace($tags,$repl,$text_repla);
        
    $text=str_replace('
    '
    ,"\n",$text_repl);
            
    $this->SetFont('Arial','B',12);
            
    $this->GetY();
            
    $y=$this->GetY()+1;
    $this->SetY($y);
    $x=$this->GetX()+75;
    $this->Setx($x);
    $this->SetFont('Arial','',12);
        
    $this->MultiCell(100,5,$text);
        
    $this->Ln(1);
        
    $y=$this->GetY();
    $this->SetY($y);
        
    $x=$this->GetX();
    $this->SetX($x);
        
    $image=$this->img_count($array['work_id']);
    if (
    $image==0)
    {

    }else{
    $this->image_gen($array['work_id'],$y);
    }
        
        
    $this->AddPage();
      }

     
    }

    function 
    img_count($work_id)
    {
    $sql=new sql;
    $sql->_select_db();
    $query=$sql->_query("select count(work_img) from work_imgs where work_id=$work_id") or die (mysql_error());
    $image_c=$sql->_fetch_array($query);
    return 
    $image_c[0];
    }



    function 
    image_gen($work_id,$y)
    {
    $sql=new sql;
    $sql->_select_db();

    $query=$sql->_query("select filen from work_imgs where work_id=$work_id ") or die (mysql_error());
    while (
    $image=$sql->_fetch_array($query))
    {
        if (
    $image[0]=='')
        {
        
        }else{
        
    $y=$this->GetY();
            if (
    $y<200)
            {
            
    $y=$this->GetY()+35;
            
    $this->SetY($y);
            
    $immagine='.././imgs/'.$image[0];
            
    $this->Image($immagine,10,$y,40);
            }else{
            
            
    $this->AddPage();
            }
            
        }
    }

    }



    //Page footer
    function Footer()
    {
        
    //Position at 1.5 cm from bottom
        
    $this->SetY(-15);
        
    //Arial italic 8
        
    $this->SetFont('Arial','I',8);
        
    //Page number
        
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
    }
    }

    //Instanciation of inherited class
    $pdf=new PDF();
    $pdf->AliasNbPages();
    $pdf->AddPage();
    $pdf->content();
    $pdf->SetFont('Times','',12);
    $pdf->Output();
    ?> 
    Qualcuno sa darmi un consiglio su come fare?

    GRAZIE

  2. #2
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    239
    uppino

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    239
    up

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.