Zend Framework

hard to extend Zend_Pdf_Page classes

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.8.4
  • Fix Version/s: None
  • Component/s: Zend_Pdf
  • Labels:
    None

Description

Hi,

I would like to join my voice on http://framework.zend.com/issues/browse/ZF-3701 and add that it's still hard to extend some pdf classes.
Well it's not hard to create a new subclass (parent properties are protected, no longer private), anyway it's extremely hard to incorporate our subclass in Zend_Pdf normal behaviour without having to rewrite the entire class.

For instance I wanted to subclass Zend_Pdf_Page to add extra methods such as drawTextOnRight(), drawTextOnCenter(), getTextWidth()... and the problem is that default Zend_Pdf_Page is hard-coded within Zend_Pdf => Zend_Pdf::load() will return a pdf with all pages being instances of Zend_Pdf_Page and not of my subclass.

It would be really nice if Zend_Pdf used same mechanism as used by Zend_Db, ie. to store name of used pdf classes (Zend_Pdf_Page, Zend_Font...) as protected properties (ex: Zend_Db_Table::$_rowClass). That way we could easily subclass and fully customize our own version of Zend_Pdf and other pdf classes.

Regards,
Remy

Activity

Hide
Dolf Schimmel (Freeaqingme) added a comment -

I think this issue should be postponed till 2.0 due to backwards compatibility (sigh...)

Show
Dolf Schimmel (Freeaqingme) added a comment - I think this issue should be postponed till 2.0 due to backwards compatibility (sigh...)
Hide
Remy Damour added a comment -

I might miss the point but I don't see backwards incompatibility.

just create a Zend_Pdf::$_pageClass property, then within Zend_Pdf class, replace all hard-coded 'Zend_Pdf_Page' with $this->_pageClass.

Such approach should be backward compatible.

Show
Remy Damour added a comment - I might miss the point but I don't see backwards incompatibility. just create a Zend_Pdf::$_pageClass property, then within Zend_Pdf class, replace all hard-coded 'Zend_Pdf_Page' with $this->_pageClass. Such approach should be backward compatible.
Hide
Jason Bury added a comment -

This may be a duplicate of ZF-4848 ("_pdfpageClass property to specify which Zend_Pdf_Page object is used to render page").

Show
Jason Bury added a comment - This may be a duplicate of ZF-4848 ("_pdfpageClass property to specify which Zend_Pdf_Page object is used to render page").

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated: