On Jul 20, 2008, at 7:52 AM, Martijn Korse wrote:

I wrote a class that could do all the calculations and store the information
about all the lines and spacing information.
To keep things clean, i decided to overload the drawText function, by
extending the Zend_Pdf_Page class and writing my own function.
But since the $page object is created form the Zend_Pdf class i had to
extend that class too, in order to let it instantiate my new page class. The problem is: both classes are filled with private variables that make
extending them impossible. So, i'm left with two options:
1) modifying the Zend Framework classes so they can hadle my new
functionality. I don't want this, because then i can never upgrade anymore 2) copying a lot code to my own classes to be able to write the output. this
i obviously also don't want.

I'm posting this here, to get some feedback. Maybe i'm overlooking some
getter/setter functions?

The Zend_Pdf_Page::rawWrite() method was intended to allow you to write your own data to the page's content stream so subclassing wouldn't strictly be necessary. Unfortunately, it had an empty implementation. I've written an implementation for that method and committed it to the framework trunk:

http://framework.zend.com/issues/browse/ZF-3704

This should eliminate your need to subclass Zend_Pdf and Zend_Pdf_Page at all. Instead, move your code to a helper layout class which can call rawWrite() on the appropriate page object.

Maybe someone can explain to me if this was done intentionaly and why?

Zend_Pdf is one of the oldest framework components. Most of the core classes haven't changed much since the initial implementations over two years ago. I believe this was probably just a mistaken choice between 'private' and 'protected' when the classes were first written. I see you've created ZF-3701 to address the visibility declarations, which I endorse.


I should mention that Kevin McArthur and I have been collaborating on a comprehensive update to Zend_Pdf for the last several months. One of the most significant pieces of the project is a true text layout engine, which handles calculation of line breaks, text alignment, and more. This message describes the enhancements:

http://www.nabble.com/Upcoming-Zend_Pdf-Enhancements-td16509067.html

The project has grown a bit since sending that original message, resulting in a complete rewrite of Zend_Pdf's core, which has taken much longer than expected. Fortunately, the core rewrite was finished last week and we are in the midst of final testing for the commercial project that spurred the development.

I would estimate that we're about two weeks away from being ready to post our reference implementation along with the proposals for what would become Zend_Pdf 2.0. I will be posting additional details to the fw-formats list when we're ready to release the code into the wild.

--

Willie Alberty
Spenlen Media
[EMAIL PROTECTED]

http://spenlen.com/

Reply via email to