Home » File Formats » File_PDF » Bug #2682
problems with addPage and multiCell
Details
| 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) |
Comments
[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().