tags:

views:

777

answers:

2

Hi,

I have a little problem with a pagebreak. The Multicell is displayed over the footer of the first page and then it breaks: How can I set the bottom margin of the page so that the break happened earlier above? Here is the example PDF: Example and here the sourcecode:

<?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');
A: 

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

Have you tried:

      $pdf->SetAutoPageBreak(True, PDF_MARGIN_FOOTER);

or

      $pdf->SetAutoPageBreak(True, where_I_want_break);
ChuckO
Yes, but the result is the same. The Multicell content is displayed over the footer :-(
grolle
Unfortunately, its just not enough to set the auto pagebreak at the footer margin. I will post my code ASAP - probably Monday.
JasonMichael
A: 

I got around this problem by using the checkPageBreak method, using a while loop. I'm using PHP 4, though. In PHP5, checkPageBreak is a private method. I think its worthwhile that we request it be made public, so that we can get more conttrol over the pages.

I also used the transaction methods so that after checking if I reached a point close to the max page height, I rolled back the transaction and did addPage().

I'll get a copy of my loop here sometime soon. This is a great library, but the auto page break is a pain with the multi-cell features.

-Jason

JasonMichael
Do you happen to have this code. I'm trying to do this as well.
Darryl Hein
I'll get it organized and posted to you.
JasonMichael
any chance you could post this code? I'm messing with TCPDF and have run into the exact same issue-- when using an HTMLMultiCell near the bottom of a page, the auto page break goes haywire and you end up with a mess on the next page.I read that this is fixed in the newer versions of TCPDF, but I'm using the library from Joomla so I can't rely on the updated code.Thanks
julio