Image('parts/ek_logo_pdf.png',10,10,70.5,12); // linea $this -> SetDrawColor(0); $this -> SetLineWidth(1); $this -> Line(11,24,199,24); //Arial bold 15 $this->SetFont('Arial','BI',18); $this ->SetTextColor(0); $this ->SetY(14.5); //Move to the right $this->Cell(90); //Title $this->Cell(100,10,'Catalogo macchine usate',0,0,"R"); //Arial piccolo $this->SetFont('Arial',"",8); $this ->SetY(22); //Move to the right $this->Cell(90); //Data e * $d=date("d/m/Y"); if ($extended) $p="* prezzi iva esclusa - "; else $p=""; $this->Cell(100,10,$p.$d,0,0,"R"); $this -> Ln(10); } //Page footer function Footer() { $this->SetY(-15); $this -> SetTextColor(0); $this->SetFont('Arial','',8); $this->Cell(0,10,"Elektrocar s.r.l. ".chr(149)." Via Y. Gagarin 25/31 ".chr(149)." 59100 Prato ".chr(149)." Tel. 0574 631128 ".chr(149)." Fax 0574 638091 ".chr(149)." www.elektrocar.it",0,0,'C'); $this->SetY(-15.5); $this->SetX(160); $this->Cell(40,0,'pagina '.$this->PageNo(),0,0,'R'); $this->SetY(-17); $this->SetX(10); $d=date("d/m/Y"); //$this->Cell(40,0,$d,0,0,'L'); $this -> SetDrawColor(0); $this -> Line (10,284,210-10,284); } } //Instanciation of inherited class $pdf=new PDF(); $pdf->AliasNbPages(); // meta $pdf->SetAuthor("pambleus"); //$pdf->SetCreator("Pambleus"); $pdf->SetKeywords("carrelli elevatori, carrello elevatore, elektrocar, usato, usati"); if ($extended) $pdf->SetSubject("Catalogo e listino carrelli elevatori usati"); else $pdf->SetSubject("Catalogo carrelli elevatori usati"); $pdf->SetTitle("Elektrocar catalogo usato"); $pdf->AddPage(); $pdf->SetFont('Arial','',12); //for($i=1;$i<=40;$i++) // $pdf->Cell(0,10,'Printing line number '.$i,0,1); $last_id_categoria=0; // controllo per scrivere intestazione categoria while ($r=mysql_fetch_array($re, MYSQL_ASSOC)) { // intestazione categoria if ($r[id_categoria]!=$last_id_categoria) { if (($pdf -> GetY())>70) $pdf -> AddPage(); //$pdf -> SetFillColor(237); $pdf -> SetFillColor(255); $pdf -> SetTextColor(0); $pdf -> SetDrawColor(14,99,186); $pdf->SetFont('Arial','B',14); $pdf -> Ln(20); $pdf -> Cell(190,10,"$r[cat_descr]",1,1,"C",1); $pdf -> Ln(10); $last_id_categoria=$r[id_categoria]; } // fine intestazione // cella di riferimento (sfondo grigio) $pdf -> SetFillColor(237); $pdf -> Cell(60,40,"",0,1,0,1); $y=($pdf -> GetY())-40; // bordo azzurro $pdf -> SetDrawColor(14,99,186); $pdf -> SetFillColor(255); $pdf -> Rect(10,$y,190,40); // bordo immagine $pdf -> SetDrawColor(0); $pdf -> SetFillColor(255); $pdf -> Rect(19,$y+1,42,32,"DF"); // immagine (vedere in fondo per pulizia cartella fpdf_temp) $query="SELECT filename FROM usato_img WHERE (id_usato=$r[id_usato] AND main=1) LIMIT 1"; $te=mysql_query($query); $t=mysql_fetch_array($te); if ($t[filename]) { $filename="imgs/".$t[filename]; $tempname="fpdf_temp/".$t[filename]; if (file_exists($filename) && !file_exists($tempname)) { // viene creata un'immagine ridotta in pdf_temp my_image($filename, $tempname); } if (file_exists($tempname)) { $pdf -> Image($tempname,20,$y+2,40); } } // riferimento $pdf -> SetY($y+33); $pdf -> SetTextColor(0); $pdf->SetFont('Arial','',10); if ($r[riferimento]) $pdf -> Cell(60,7,"Rif. ".$r[riferimento],0,0,"C"); // marca e modello $mm=ucfirst($r[marca]); if ($mm && $r[modello]) $mm.=" "; $mm.=$r[modello]; $pdf -> SetY($y+10); $pdf -> Cell(67); $pdf->SetFont('Arial','B',14); $pdf -> SetTextColor(14,99,186); $pdf -> Cell(0,0,$mm); // subcat e anno $s=$r[subcat]; if ($s && $r[anno]) $s.=" - "; if ($r[anno]) $s.="Anno ".$r[anno]; $pdf -> SetY($y+17); $pdf -> Cell(67); $pdf -> SetTextColor(0); $pdf->SetFont('Arial','',12); $pdf -> Cell(0,0,$s); // portata e montante $s=""; if ($r[portata] || $r[baricentro]) $s="Portata "; if ($r[portata]) $s.=$r[portata]." kg "; if ($r[baricentro]) $s.="a ".$r[baricentro]." mm "; $t=""; if ($r[montante] || $r[alzata]) $t.="Montante "; if ($r[montante]) $t.=($r[montante])." "; if ($r[alzata]) $t.=$r[alzata]." mm "; if ($s && $t) $s.="- "; $s.=$t; $pdf -> SetY($y+21.5); $pdf -> Cell(67); $pdf -> Cell(0,0,$s); // descrizione e note_pub $s=$r[descrizione]; if ($r[descrizione] && $r[note_pub]) $s.=" - "; $s.=$r[note_pub]; // gli a capo diventano trattini spaziati $s=str_replace(chr(10)," - ",$s); $s=str_replace(chr(13),"",$s); $parola = explode(" ", $s); // toglie spazi prima e dopo e elimina i vuoti foreach ($parola as $i => $t) { $parola[$i]=trim($parola[$i]); if (!$parola[$i]) unset($parola[$i]); } $riga[0]=""; $riga[1]=""; $riga[2]=""; $riga[3]=""; $j=0; foreach ($parola as $i => $t) { if ($pdf->GetStringWidth($riga[$j]." ".$t)>115) $j++; if ($j>3) $j=3; if ($riga[$j]) $riga[$j].=" "; $riga[$j].=$t; } if ($riga[3]) $riga[2]=$riga[2]."..."; $pdf -> SetY($y+26); $pdf -> Cell(67); $pdf -> Cell(0,0,$riga[0],0); $pdf -> SetY($y+30.5); $pdf -> Cell(67); $pdf -> Cell(0,0,$riga[1],0); $pdf -> SetY($y+35); $pdf -> Cell(67); $pdf -> Cell(0,0,$riga[2],0); // prezzo $pdf -> SetY($y+10); $pdf -> Cell(150); $pdf->SetFont('Arial','B',14); $pdf -> SetTextColor(244,0,29); if ($r[prezzo] && can_he_do($user,"prezziusato") && $extended) { $x=$r[prezzo]; if ($r[prezzo]>=1000) $x=substr($r[prezzo],0,-3).".".substr($r[prezzo],-3); $pdf -> Cell(32,0,chr(128)." ".$x,0,0,"R"); $pdf -> SetY($y+9.5); $pdf -> Cell(180); $pdf->SetFont('Arial','B',10); $pdf ->SetTextColor(0); $pdf -> Cell(30,0,"*"); } $pdf->SetFont('Arial','B',14); // linea separazione //$pdf -> SetDrawColor(237); $pdf -> Line (78,$y+13.2,192,$y+13.2); // reimposta a fine cella $pdf -> SetY($y+40); } //******************************************************************************************************** $pdf->Output(); //******************************************************************************************************** // pulizia cartella fpdf_temp // cancella ogni file .jpg che non ha un corrispondente in imgs if ($dir = @opendir("fpdf_temp")) { while (($file = readdir($dir)) !== false) if (substr($file,-4)==".jpg") if (!file_exists("imgs/".$file)) unlink("fpdf_temp/".$file); closedir($dir); } function my_image($filename, $tempname) // crea un'immagine ridotta (120x90) quality=100% { // controlli esistenza fatti sopra list($width, $height, $type, $attr) = getimagesize($filename); $im = @imagecreatefromjpeg($filename); $in = @imagecreatetruecolor(120, 90); if ($b= imagecopyresampled ( $in, $im, 0, 0, 0, 0, 120, 90, $width, $height)); imagejpeg($in,$tempname,100); imagedestroy($im); imagedestroy($in); } ?>