TCPDF PageBreak ile ilgili sorun

6 Cevap php

Ben bir PageBreak küçük bir sorun var. Multicell ilk sayfanın alt üzerinde görüntülenir ve daha sonra bu tatili: mola daha önce yukarıdaki oldu böylece nasıl sayfanın alt kenar ayarlayabilirsiniz? Example ve burada Sourcecode: İşte örnek PDF:

<?php require_once('../tcpdf/config/lang/eng.php'); 
  require_once('../tcpdf//tcpdf.php'); 

  class MYPDF extends TCPDF {
    public function Header() { 
      $auto_page_break = $this->AutoPageBreak;
      $this->SetAutoPageBreak(false,0); 
      $this->setJPEGQuality(100); $img_file = 'images/mandanten/ce_background.jpg';       
      $this->Image($img_file, $x=160, $y=72, $w=36, $h=200, $type='', $link='', $align='', $resize=true, $dpi=150, $palign='', $ismask=false, $imgmask=false, $border=0);        
      $this->SetAutoPageBreak($auto_page_break); } 
   }

 $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 
 $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('tmpAutor');  
 $pdf->SetTitle('tmpTitle'); $pdf->SetSubject('tmpSubject'); 
 $pdf->SetKeywords('tmp');   $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); 
 $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));                
 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); 
 $pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);                                   
 $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);  
 $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);             
 $pdf->SetAutoPageBreak(True, PDF_MARGIN_BOTTOM); 
 //set image scale factor 
 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
 //set some language-dependent strings 
 $pdf->setLanguageArray($l); $pdf->AddPage(); 
 $pdf->SetFont('freesans', '', 16); 
 $pdf->Cell(0, 10, 'Headline', 0, 1, 'L'); 
 $pdf->SetFont('freesans', '', 11); 
 // Some Dummy Unicode content 
 $tmp = 'Lorèm ìpsum dolor sìt åmèt, čonsètètur sådìpsčìng èlìtr, sèd dìåm nonumy èìrmod tèmpor ìnvìdunt ut låborè èt dolorè mågnå ålìquyåm èråt, sèd dìåm voluptuå. åt vèro èos èt åččusåm èt justo duo dolorès èt èå rèbum. Stèt člìtå kåsd gubèrgrèn, no sèå tåkìmåtå sånčtus èst Lorèm ìpsum dolor sìt åmèt. Lorèm ìpsum dolor sìt åmèt, čonsètètur sådìpsčìng èlìtr, sèd dìåm nonumy èìrmod tèmpor ìnvìdunt ut låborè èt dolorè mågnå ålìquyåm èråt, sèd dìåm voluptuå. åt vèro èos èt åččusåm èt justo duo dolorès èt èå rèbum. Stèt člìtå kåsd gubèrgrèn, no sèå tåkìmåtå sånčtus èst Lorèm ìpsum dolor sìt åmèt.wåèdr';

$pdf->MultiCell(140, 0, $tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp, 0, 'J', 0, 0, '', '', true, 0,true);    
$pdf->Output('example_051.pdf', 'I');

6 Cevap

$pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(True, PDF_MARGIN_BOTTOM);

Eğer denedim:

      $pdf->SetAutoPageBreak(True, PDF_MARGIN_FOOTER);

veya

      $pdf->SetAutoPageBreak(True, where_I_want_break);

Aynı sorunu vardı, ancak autopagebreak kapalı ayarlar TCPDF örneklerinden birinden bir yöntem kullanılır, hücreden dışarı yazar ve ardından tekrar autopagebreak döner:

    public function WriteCellText( $CellValue, $x, $y,$w, $h){

            $bMargin = $this->getBreakMargin();
            $auto_page_break = $this->AutoPageBreak;
            $this->SetAutoPageBreak(false, 0);
            $this->SetXY($x, $y, true);
            $this->Cell($w,$h, $CellValue, 0, 0, 'L', 0, '', 0, true);
            $this->SetAutoPageBreak($auto_page_break, $bMargin);
    }

Jason gibi,

I also use the checkPageBreak() function. I am using version 5.9.113 of tcpdf. I had to modify the changePageBreak() function from protected to public. Then in a loop that output each row of data from a database table using MultiCell() with custom width cells, I check for new page, handle accordingly, and it works like a charm. I do not have to use transaction methods to handle new pages.

İşte tüm işleyen kod döngü bir alıntıdır:

while($data = mysql_fetch_assoc($result))
{
    $pdf->MultiCell(20,6,$data['date'],0,'C',0,0);
    $pdf->MultiCell(40,6,$data['refnumber'],0,'C',0,0);
    $pdf->MultiCell(66,6,$data['memo'],0,'L',0,0);
    $pdf->MultiCell(20,6,$data['linetotal']),0,'R',0,0);
    $pdf->Ln();
    if($pdf->checkPageBreak()) $pdf->Ln();
    }

Yeni bir sayfa eklendiğinde checkPageBreak () işlevi true döndürür. Bu durumda, ben yeni bir hat ile yaptığımız gibi gerekli ek görevleri gerçekleştirebilirsiniz.

Bu MutliCell ile başkasına ve özel genişlik sorunu yardımcı olur umarım.

Şans

Ben bir süre döngü kullanarak, checkPageBreak yöntemini kullanarak bu soruna var. Gerçi, PHP 4 kullanıyorum. PHP5'ta, checkPageBreak özel bir yöntemdir. Ben biz sayfaları üzerinde daha fazla conttrol alabilirsiniz böylece, kamuya istemek onun değerli düşünüyorum.

Ben maksimum sayfa yüksekliğine yakın bir noktaya ulaştı eğer kontrol ettikten sonra, ben addPage () işlem geri alınır ve yaptım ki ben de işlem yöntemleri kullanılır.

Ben bazen yakında burada benim döngü bir kopyasını alırsınız. Bu büyük bir kütüphane, ancak otomatik sayfa sonu çok hücre özellikleri ile bir ağrıdır.

-Jason

Pleas yerine çok hücreli bir writeHTMLCell işlevini deneyin

değişim

$pdf->MultiCell(140, 0, $tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp."<br><br>".$tmp, 0, 'J', 0, 0, '', '', true, 0,true); 

karşı

$this->writeHTMLCell(0, 25, 25, 250,'Footer value', 0, 0, 0, true, 'C', true);

Yoksa sen, gibi TCPDF altbilgi yöntemi geçersiz kılabilirsiniz

// Position at 15 mm from bottom
    $this->SetY(-15);
    // Set font
    $this->SetFont('helvetica', 'B', 8);
//Userdefind Function -Testing

$pg_num = $this->getPage();
$page_height = $this->getPageHeight();
$ph = $page_height;
$this->writeHTMLCell(0, 25, 25, $ph-19.4,'footer data', 0, 0, 0, true, 'C', true);
$this->writeHTMLCell(0, 25, 25, $ph-9.4,'footer data', 0, 0, 0, true, 'L', true);