Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.3.3

Bug #2682 problems with addPage and multiCell
Submitted: 2004-11-03 20:47 UTC
From: roberto at solary dot net Assigned: mdjukic
Status: Closed Package: File_PDF
PHP Version: 4.3.7 OS: Linux
Roadmaps: (Not assigned)    

 [2004-11-03 20:47 UTC] roberto at solary dot net
Description: ------------ addPage doesn't set font for a new page. Reproduce code: --------------- $this->_font_family always is null and doesn't setFont for the new page. if ($this->_font_family) { $this->setFont($this->_font_family, $style, $this->_font_size_pt); } Expected result: ---------------- The entire file is written. Actual result: -------------- Only the first page is written.


 [2004-11-05 23:36 UTC] keng at dis-corp dot com
I made a couple of changes to get this working for me. Below are the changes... function _beginPage(...) { : : //$this->_font_family = ''; //Keng - Don't want to reset this information. : : } setFont(...) { : : /* Need to let the font information be written out each time, so when we do go to a new page, we have the font information. if ($this->_font_family == $family && $this->_font_style == $style && $this->_font_size_pt == $size) { return; } */ : : } Hope this helps.
 [2004-11-06 15:02 UTC] roberto at solary dot net
Thks, but what happend with it's autobreak? I made this in addPage function: # Here _font_family isset $family = $this->_font_family; . . . if ($family) { $this->setFont($family, $style, $this->_font_size_pt); }
 [2004-11-08 15:21 UTC] keng at dis-corp dot com
What do you mean about the autobreak? Autobreak works for me, but I had to make sure that I commented out the information in the setFont() function. This is what I was doing: $text = file_get_contents("test.txt"); $pdf = &File_PDF::factory('L', 'mm', 'Letter'); $pdf->open(); $pdf->setMargins("13", "13", "13"); $pdf->setAutoPageBreak(true, "13"); $pdf->SetFont('Courier','',9); $pdf->AddPage(); //$pdf->SetFont('Courier','',9); //Before the fix I proposed, you had to set this just after setting the page. Couldn't do it before since, AddPage() clears _font_family variable in beginDoc(). $pdf->Write(4, $text); $pdf->Output('test.pdf', true); What I found is that you have to set the font after doing an AddPage() call. If you do it before, it just doesn't work right. The reason for this is beginDoc() is clearing the _font_family variable in beginDoc(). With the changes I have done, you should be able to add the setFont() before the addPage() and things should work. Hope this helps.
 [2004-11-08 15:24 UTC] keng at dis-corp dot com
Sorry about that, beginDoc should be _beginPage().
 [2004-12-05 11:43 UTC] dufuz
Really think that this summary is wrong. It isn't tricky to fix this, but one has to think about, like File_PDF is at the moment, then if header() uses setFont, that will overtake what was set before addPage and be used on the rest of the pages (until another setFont comes in). I haven't yet reached Marko, but I'll look into this with him and try to find some sensable solution (if it's sensable at all to use setFont before addPage, IMHO it isn't that much really)
 [2005-05-26 23:33 UTC] mdjukic
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on In case this was a website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.