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.

Comments

[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.

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.

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)

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 pear.php.net.
In case this was a pear.php.net 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.