  | 
              
	              
	                
  
    
	 
        [สอบถาม] ปัญหาการ Print PDF แล้วมัยขึ้น TCPDF ERROR: Some data has already been output, can't send PDF file ครับ     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                พอผมกดสั่ง พิม มันจะ ขึ้น ข้อความว่า 
 
TCPDF ERROR: Some data has already been output, can't send PDF file นะคครับ 
 
รบกวนช่วยดู โค้ดด้วยครับผม 
 
Code (PHP) 
//////////////////////////////////////////////////////////////////////////////////////////////
require_once("html2pdf/setPDF.php"); // ไฟล์สำหรับกำหนดรายละเอียด pdf 
// เพิ่มหน้าใน PDF 
$pdf->AddPage();
// กำหนด HTML code หรือรับค่าจากตัวแปรที่ส่งมา
//	กรณีกำหนดโดยตรง
//	ตัวอย่าง กรณีรับจากตัวแปร
// $htmlcontent =$_POST['HTMLcode'];
$html1="<table width='535' border='1'>
  <tr>
    <td colspan='5' align='center'><img width='300' height='300' src='$piclogo' /></td>
  </tr>
  <tr>
    <td colspan='4'>Project ID = $projectID</td>
    <td>Project Name = $nameproject </td>
  </tr>
  <tr>
    <td colspan='5' align='center'>Work</td>
  </tr>
  <tr>
    <td>ลำดับ</td>
    <td>จำนวน</td>
    <td>หน่วย</td>
    <td>รายการ</td>
    <td>ราคา</td>
  </tr>";
  ?>
  <?php
  	$i=1;
	//Begin While
	$select_quote_print = "select * from tblquotation_detail where quid = '$ID'";
	$query_quote_print = mysql_query($select_quote_print);
	while($quote_print = mysql_fetch_array($query_quote_print))
	{
  ?>
<?php
$html2="		
  <tr>
    <td> $i </td>
    <td>".$quote_print['amount']."</td>
    <td>".$quote_print['unit']."</td>
    <td>".$quote_print['work_name']."</td>
    <td>". number_format($quote_print['total'],2)."</td>
  </tr>";
  ?>
   <?php $i++; } //END While?>
  <?php
  $html3="
  <tr>
    <td colspan='4'>รวม</td>
    <td>". number_format($total_cost,2)."</td>
  </tr>
  <tr>
    <td colspan='4'>ภาษีมูลค่าเพิ่ม ($persent)</td>
    <td>". number_format($numtax,2)."</td>
  </tr>
  <tr>
    <td colspan='4'>รวมทั้งสิ้น</td>
    <td>". number_format($total_all,2)."</td>
  </tr>
</table>";
$html_all = $html1+$html2+$html3;
$html_all = stripslashes($html_all);
$html_all = AdjustHTML($html_all);
// สร้างเนื้อหาจาก  HTML code
$pdf->writeHTML($html_all, true, 0, true, 0);
// เลื่อน pointer ไปหน้าสุดท้าย
$pdf->lastPage();
// ปิดและสร้างเอกสาร PDF
$pdf->Output('Test.pdf', 'I');
}
 
 
  Tag : PHP, MySQL, HTML/CSS, Ajax               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2013-11-28 15:26:10 | 
                      By :
                          nutzaaclub | 
                      View :
                          2676 | 
                      Reply :
                          9 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 พิมออก แล้วนะครับ ต้องไปใส่ ob_end_clean(); ก่อน output แต่มีปัญหาอีกอย่างครับ คือ Pdf ออกมา หน้าตาเป็นแบบนี้ครับ 
ผมพลาดอะไรไปหรือเปล่าครับ 
 
                         
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2013-11-28 15:37:44              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-11-28 15:35:59 | 
                        By :
                            nutzaaclub | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ผมว่าน่าจะเป็ฯที่ while นะครับมัน ลูปข้อมูลออกมาไม่ได้มั้งครับ ลองดูนะครับ 
 
https://www.thaicreate.com/php/forum/065270.html                        
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2013-11-28 16:52:08              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-11-28 16:51:00 | 
                        By :
                            dagonov | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ช่วงบรรทัดที่ 27-28 
Code (PHP) 
?>
<?php
  
ลบออกครับ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-11-28 17:05:22 | 
                        By :
                            itpcc | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (PHP) 
$ID
  
มาจากไหนครับ?                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-11-28 19:10:12 | 
                        By :
                            itpcc | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 แล้วทำไมไม่หาคลาสง่าย ๆ ตัวอื่นใช่ล่ะครับ...ทำไมต้องเจาะจงเป็น html2pdf ... 
PHP to PDF ก็มีนะ เพราะยัง ๆ ก็ต้องดึงค่าจาก database อยู่แล้วนิ่ ??                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-11-28 19:19:34 | 
                        By :
                            apisitp | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (PHP) 
$html_all = $html1+$html2+$html3;
  
Code (PHP) 
$html_all = $html1.$html2.$html3;
                         
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-11-28 21:29:14 | 
                        By :
                            itpcc | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
      		  
	
     | 
   
 
                 |