ZF-7144: hard to extend Zend_Pdf_Page classes

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

Comments

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

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.

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