It's currently quite complicated to output text with Zend_Pdf, because the positioning and wrapping of every text piece has to be done manually. Instead this proposal introduces a text cursor and a method to add a text block, which enables to Zend_Pdf to handle the basic text flow operations.
3. Component Requirements, Constraints, and Acceptance Criteria
Most requirements take the form of "foo will do ...." or "foo will not support ...", although different words and sentence structure might be used. Adding functionality to your proposal is requirements creep (bad), unless listed below. Discuss major changes with your team first, and then open a "feature improvement" issue against this component.
This proposal will not reengineer Zend_Pdf.
This proposal will instead add some new basic methods, that extend the current functionality.
This proposal will not hinder reengineering Zend_Pdf. Everything that gets added is an API improvement, designed from a component user point of view.
The new methods will be optional.
Therefore, Zend_Pdf will stay completely backward compatible.
4. Dependencies on Other Framework Components
Zend_Pdf
5. Theory of Operation
The basic method to add text is still drawText(), but the parameters $x and $y will be optional, if a text cursor is set. The cursor runs from left to right or right to left. Every time a new text fragment is drawn the cursor advances automatically. If a width is set, the cursor will automatically add a new text line wrapping words as needed. It's possible to change the text style between text fragments.
In addition a new method drawTextBlock() is added that allows drawing text left or right aligned, centered or justified. The later two alignments are only possible with this method, but the whole text block can only have one text style.
3 Comments
comments.show.hideJul 02, 2009
Nico Edtinger
<p>I've uploaded what I currently have:</p>
<table><tbody>
<tr>
<td><p>new Zend/Pdf/Page.php with text drawing improvements</p></td>
<td><p><a href="http://public.edtinger.at/2009/zf/vim_pdf/Zend_Pdf_Page.phps">http://public.edtinger.at/2009/zf/vim_pdf/Zend_Pdf_Page.phps</a></p></td>
</tr>
<tr>
<td><p>diff to last SVN rev</p></td>
<td><p><a href="http://public.edtinger.at/2009/zf/vim_pdf/Zend_Pdf_Page.diff">http://public.edtinger.at/2009/zf/vim_pdf/Zend_Pdf_Page.diff</a></p></td>
</tr>
<tr>
<td><p>test file</p></td>
<td><p><a href="http://public.edtinger.at/2009/zf/vim_pdf/test.php">http://public.edtinger.at/2009/zf/vim_pdf/test.php</a></p></td>
</tr>
<tr>
<td><p>source of test file</p></td>
<td><p><a href="http://public.edtinger.at/2009/zf/vim_pdf/test.phps">http://public.edtinger.at/2009/zf/vim_pdf/test.phps</a></p></td>
</tr>
</tbody></table>
Jan 22, 2010
Nils Caspar
<p>Any news on this proposal? Looks useful to me. <ac:emoticon ac:name="smile" /></p>
Sep 24, 2011
Jasper Kuperus
<p>Nice proposal! I am certainly going to use this and would like to see it in Zend. However, I found a small bug I think.</p>
<p>The method drawTextBlock has a reference to the variable widht. This should probably be $width?</p>