http://qs321.pair.com?node_id=661356


in reply to Dynamic tables using PDF::Template

Wow. Two questions and two doozies. Dynamically determining column width from data is really really difficult, particularly for outputs which are paginated, dynamically formatted, and printed. It could've been fixed pretty easily, except for the fact that PDF::Template is a single-pass transformer. All the fixes require a two-pass engine and rewriting the engine just for this situation was deemed too much work for the effort.

The best solution I've found is to use percentages and keep tweaking. Alternately, you can actually have the widths be variable and calculate things in your code.

As for more permanent solutions, take a look at Excel::Template::Element::Cell::AutoSize. While it's for Excel::Template and not PDF::Template, they were written off the same engine (E::T is just a rewrite of P::T) and so the technique of adding your own elements dynamically works the same for both.


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?