Zend Framework

explain how to change font color

Details

  • Type: Docs:  Improvement Docs: Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0.0
  • Fix Version/s: 1.11.1
  • Component/s: Zend_Pdf
  • Labels:
    None
  • Language:
    English

Description

The PDF docs don't really explain how to set font color. It appears the only way to do it is to create a new Style, and then set the font and color that way, as in:

$style = new Zend_Pdf_Style();
$style->setFillColor(new Zend_Pdf_Color_HTML('#000077'));
$style->setFont(Zend_Pdf_font::fontWithName(Zend_pdf_font::FONT_HELVETICA),10);
$page->setStyle($style);

It might also be helpful to modify the color section of the manual to explicitly list where color can be used (i.e. within a style object, and not in a page object, etc.)

Activity

Hide
Willie Alberty added a comment -

As with any other PDF drawing operations, text is drawn using the current fill color of the content stream's (page's) graphic state:

$page->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));  // red

Zend_Pdf_Style objects allow you to set multiple attributes of the graphics state at once, but are not required.

Show
Willie Alberty added a comment - As with any other PDF drawing operations, text is drawn using the current fill color of the content stream's (page's) graphic state:
$page->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));  // red
Zend_Pdf_Style objects allow you to set multiple attributes of the graphics state at once, but are not required.
Hide
Wil Sinclair added a comment -

Does this information belong in the reference guide? If so, could you please add it or reassign to Alex, Willie? Otherwise resolve it as 'not an issue'. Thanks.

Show
Wil Sinclair added a comment - Does this information belong in the reference guide? If so, could you please add it or reassign to Alex, Willie? Otherwise resolve it as 'not an issue'. Thanks.
Hide
Willie Alberty added a comment -

Assigning to Alexander for documentation update.

Show
Willie Alberty added a comment - Assigning to Alexander for documentation update.
Hide
Marc Hodgins added a comment -

Patch to documentation attached.

Show
Marc Hodgins added a comment - Patch to documentation attached.
Hide
Marc Hodgins added a comment -

Patch applied to trunk in r23406, merged to 1.11 release branch in r23407

Show
Marc Hodgins added a comment - Patch applied to trunk in r23406, merged to 1.11 release branch in r23407

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: