Zend_Pdf_Page::setStyle() method dumps style instructions immediately
and doesn't track style object modifications.
So you have to apply new or modified style again if you want to change
current style:
-----------------
$style = new Zend_Pdf_Style();
$style->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 1));
$page->setStyle($style);
...
$style->setFillColor(new Zend_Pdf_Color_Rgb(.5, .5, .5));
$page->setStyle($style);
----------
Please note that style is only a "container" for a set of page
properties. You can change each of these properties individually like this:
-----------------
$page->setFillColor($color);
$page->setLineDashingPattern($pattern);
$page->setFont($font);
...
----------
Styles are useful if you have several sets of common drawing options and
want to switch between them instead of applying all options each time:
-----------------
$style1 = new Zend_Pdf_Style();
$style1->setFillColor($color1);
$style1->setLineDashingPattern($pattern1);
$style1->setFont($font1);
...
$style2 = new Zend_Pdf_Style();
$style2->setFillColor($color2);
$style2->setLineDashingPattern($pattern2);
$style2->setFont($font2);
...
$page->setsStyle($style1);
...
$page->setsStyle($style2);
...
$page->setsStyle($style1);
...
$anotherPage->setsStyle($style1);
...
----------
With best regards,
Alexander Veremyev.
Jasp182 wrote:
When I pass a Zend_Pdf_Style object to the setStyle function, does it
maintain a reference to the original object? Meaning...to change properties
of the style object, do I need to call setStyle again, or just call the set
function on the local style object itself.
For example, I have
$style = new Zend_Pdf_Style();
$style->setFillColor( new Zend_Pdf_Color_Rgb( 1, 1, 1 ) );
$pdf_page->setStyle( $style );
if I call this within the same function :
$style->setFillColor( new Zend_Pdf_Color_Rgb( .5, .5, .5 ) );
do I need to call setStyle again, or will this change take effect on the
style object inside my pdf_page object?
I hope this was clear.
Thanks,
Rich