|  | 
	                
  
    | 
	 
        เกี่ยวกับ pdf พอขึ้นหน้าใหม่แล้วมันเลื่อนไม่ตรงกัน     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | <?php //$day = date("d").'-'.date("m").'-'.date("Y")+543;
 define('FPDF_FONTPATH','font/');
 require('fpdf/fpdf.php');
 
 $pdf=new FPDF();
 $pdf->AddFont('angsana','','angsa.php');
 $pdf->AddFont('angsana','B','angsab.php');
 $pdf->AddFont('angsana','I','angsai.php');
 $pdf->AddFont('angsana','BI','angsaz.php');
 $pdf->AddPage();
 //$pdf->SetFont('angsana','B',16);
 //$pdf->Cell(0,10,'Welcome to www.ThaiCreate.Com',0,1)
 //$pdf->Cell(0,20,'Version 2009',0,1,"C");
 $pdf->Image('img/order.gif',0,0,0,0,'','');
 
 $pdf->SetFont('angsana','B',16);
 $pdf->setXY( 10, 60  );
 $pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' , 'รหัส     '.$time ) );
 
 $pdf->SetFont('angsana','B',16);
 $pdf->setXY( 10, 70  );
 $pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' , 'ชื่อ        '.$cu[Company]));
 
 $pdf->SetFont('angsana','B',16);
 $pdf->setXY( 10, 80  );
 $pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' , 'ที่อยู่     '.$cu[Address].' จ.'.$cu[county]) );
 
 $pdf->SetFont('angsana','B',16);
 $pdf->setXY( 120, 60  );
 $pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' , 'วันที่     '.date("d").' - '.date("m").' - '.(date("Y")+543)) );
 
 $pdf->Ln();
 $pdf->SetX(20);
 $pdf->SetY(90);
 $pdf->Cell(18,8,iconv( 'UTF-8','cp874' , 'ลำดับที่'),1,0,'L');
 $pdf->Cell(50,8,iconv( 'UTF-8','cp874' , 'รายการ'),1,0,'C');
 $pdf->Cell(20,8,iconv( 'UTF-8','cp874' , 'จำนวน'),1,0,'C');
 $pdf->Cell(30,8,iconv( 'UTF-8','cp874' , 'จำนวนเงิน'),1,0,'C');
 $pdf->Cell(30,8,iconv( 'UTF-8','cp874' , 'ยอดคงค้าง'),1,0,'C');
 $pdf->Cell(40,8,iconv( 'UTF-8','cp874' , 'ยอดชำระ'),1,0,'C');
 
 for ($i=0;$i<count($sess_idpro);$i++){
 $total_unit2 = $sess_count[$i]*$sess_Price[$i];
 $total2 = $total2+$total_unit2;
 
 $pdf->Ln();
 $pdf->SetX(20);
 $pdf->SetY(98+(8*$i));
 $pdf->Cell(18,8,iconv( 'UTF-8','cp874' ,($i+1)),1,0,'L');
 $pdf->Cell(50,8,iconv( 'UTF-8','cp874' ,$sess_Num_Product[$i]),1,0,'C');
 $pdf->Cell(20,8,iconv( 'UTF-8','cp874' ,$sess_count[$i]),1,0,'C');
 $pdf->Cell(30,8,iconv( 'UTF-8','cp874' ,number_format($sess_Price[$i])),1,0,'C');
 $pdf->Cell(30,8,iconv( 'UTF-8','cp874' ,''),1,0,'C');
 $pdf->Cell(40,8,iconv( 'UTF-8','cp874' ,number_format($total_unit2)),1,0,'C');
 $sety = 98+(8*$i);
 $totel_y = $total_y + $sety;
 }
 
 $pdf->SetFont('angsana','B',16);
 $pdf->setXY( 10, $totel_y + 15  );
 $pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' , 'หมายเหตู') );
 
 $pdf->SetFont('angsana','B',16);
 $pdf->setXY( 140, $totel_y + 25  );
 $pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' , 'เป็นจำนวนเงินทั้งหมด   '.$total2.'   บาท') );
 
 $pdf->SetFont('angsana','B',16);
 $pdf->setXY( 10, $totel_y + 35  );
 $pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' , 'โปรดสั่งจ่ายในนามบริษัทเท่านั้น') );
 
 $pdf->Image('img/order_03.gif',10,$totel_y + 45,0,0,'','');
 $pdf->Image('img/order_05.gif',65,$totel_y + 45,0,0,'','');
 $pdf->Image('img/order_07.gif',135,$totel_y + 45,0,0,'','');
 
 $pdf->Output("pdf/$time.pdf","F");
 ?>
 PDF Created Click <a href="pdf/<?=$time?>.pdf">here</a> to Download
 <?
 
 สำเร็จถ้าไม่เกิน15รายการ
 
  
 ไม่สำเร็จ ถ้าเกิน15รายการ
 
  
 
 
 Tag : PHP, HTML/CSS
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2013-10-15 13:22:17 | By :
                          gwe1234 | View :
                          1391 | Reply :
                          3 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | มันเลื่อนไม่ตรงกันแบบไหนครับ ดูรูปแล้วไม่เข้าใจ 
 ของผมใช้ดึงค่าจาก database ตรง ๆ มันก็ตัดหน้าให้อัติโนมัตินะ
 
 
 <? 
require_once('config.php'); 
	mysql_connect($host,$user,$pw) or die("ติดต่อ HOST ไม่ได้");
	mysql_select_db($dbname) or die("ไม่สามารถติดต่อฐานข้อมูลได้");
require('thaipdfclass.php'); //แต่ผมใช้ Class ตัวนี้
$pdf=new ThaiPDF(); 
$pdf->SetThaiFont(); 
$pdf->AddPage(); 
class PDF extends ThaiPDF
{
function Header()
{
	$this->Image('logo.jpg',132,8,30,30);
	$this->SetFont('CordiaNew','B',20);
	$this->Ln(30); 
		
	$this->Cell(0,7,'รายชื่อ นิสิต/นักศึกษา ผู้มีโรคประจำตัว',0,0,'C');
		
	$this->Ln(10);
$this->SetFont('CordiaNew','B',14);  
$this->SetTextColor(0,0,0); 
$this->Cell(10,6,'ลำดับ',1,0,'C'); 
$this->Cell(55,6,'ชื่อ-นามสกุล',1,0,'C'); 
$this->Cell(80,6,'สถาบัน',1,0,'C'); 
$this->Cell(50,6,'อาการ',1,0,'C'); 
$this->Cell(60,6,'ผู้ปกครอง',1,0,'C'); 
$this->Cell(25,6,'เบอร์ติดต่อ',1,1,'C'); 
}}
$pdf=new PDF('L' , 'mm' , 'A4' ); 
$pdf->SetThaiFont(); 
$pdf->AddPage(); 
		$strSQL1 = "SELECT * FROM tb_order where  disease <> '' AND disease <> '-' AND disease <> ' -' AND disease <> '  -'  AND disease NOT LIKE '%ไม่มี%' ";
		$objQuery1=mysql_db_query($dbname,$strSQL1); 
		$num1=mysql_num_rows($objQuery1); 
			$t = 1;
		while($objResult1 = mysql_fetch_array($objQuery1))
		{
				$id = $objResult1['id_o'];
		$strSQL3 = "SELECT * FROM tb_student where id = $id ORDER BY `institute` ASC";
		$objQuery3=mysql_db_query($dbname,$strSQL3); 
		$num3=mysql_num_rows($objQuery3); 
		$objResult3 = mysql_fetch_array($objQuery3);
$pdf->Cell(10,6,''.$t,1,0,'C'); 
$pdf->Cell(55,6,'  '.$objResult3[titleName].$objResult3[firstName].'  '. $objResult3[lastName],1,0,'L'); //ชื่อ
$pdf->Cell(80,6,'  '.$objResult3[institute],1,0,'L'); 
$pdf->Cell(50,6,'  '.$objResult1[disease],1,0,'L'); 
$pdf->Cell(60,6,'  '.$objResult1[EmergencyName],1,0,'L'); 
$pdf->Cell(25,6,'  '.$objResult1[MobileEmergency],1,1,'L'); 
$t++ ;
}
$pdf->Output(); 
	
?>   <STRONG>Code (PHP)</STRONG>
คลิกเพื่อดูของจริง
 
 |  
              | 
 ประวัติการแก้ไข
 2013-10-15 13:40:35
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-10-15 13:34:25 | By :
                            apisitp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ถ้าสั่งไม่เกิน1หน้ากระดาษ  มันจะเป็นเหมือนรูปแรก พอดี แต่ถ้าสั่งเกิน 1หน้ากระดาษ มันจะ เลื่อน เป็นที่ละหน้าเหมือนรูปที่2
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-10-15 13:36:40 | By :
                            gwe1234 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลองหาวิธีตัด page ขึ้นหน้าใหม่ โดยใช้ที่ session ดูครับ.... ทำคนละแบบคำตอบอาจไม่ตรงมากหนัก
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-10-15 13:41:58 | By :
                            apisitp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |