Introduction.
There was a lot of requests for tables, text blocks, headers, footnotes and other text decoration Zend_Pdf functionality in ZF mailing lists.
Some abstract document model has to be developed to make all these functionality consistent and completed.
Good candidate is a document model lain under XSL-FO standard (http://www.w3.org/TR/xsl/).
The idea is not just to implement XSL-FO => PDF transformation, but to develop an API which utilizes XSL-FO document model features.
Such API should be extended step by step to completely cover XSL-FO standard, but it's a question of future development. First goal is to provide standard text decoration functionality.
Here is a draft of the API, which is intended for discussion.
Base concepts.
Abstract document model doesn't depend on Zend_Pdf implementation and in principle may be taken out into a separate module (Zend_Document ???).
Nevertheless it may use some Zend_Pdf objects as an input. Ex. fonts may be specified by name ('Helvetica') or by font object (Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA))
Drawing output is organized into sequenced pages.
Output pages may be directly transformed into Zend_Pdf_Page objects and attached to PDF document (Zend_Pdf object).
Each output page is constructed using named page template and content.
There are two types of page templates: simple page layout (corresponds to '/fo:root/fo:o:layout-master-set/fo:simple-page-master' objects) and page sequence layout (corresponds to '/fo:root/fo:o:layout-master-set/fo:page-sequence-master' objects).
Simple page layout templates define pages size, orientation, regions (see fo:simple-page-master and fo:region-body descriptions), margins, number of columns in the body region and so on.
Page sequence layout templates allow to construct sequences of pages with a special layout for first N pages, odd/even pages, blank pages and so on.
Content is organized into pages using specified page layout. The result is a sequence of output pages.
There are two types of the content:
- static content is applied to all pages in a sequence containing specified region.
- content flow is a common content which is written to the specified region.
Content consists of a sequence of text blocks (paragraphs), tables or list blocks.
Each block has a common set of text decoration options: font, font size, font style, alignment, color, line spaces and so on. Take a look at fo:block to see full list of allowed properties.
Blocks may be organized into block containers (fo:block-container). Block container may also be absolutely positioned on a page.
Each block may contain plain text as well as other block level formatting objects (separate characters, images, inline areas and so on, take a look at Inline-level Formatting Objects for more details).
API
It's a draft version of class skeletons, and it's intended to be discussed
Use cases
To be continued...
------------------------------------------------
1 Comment
comments.show.hideSep 24, 2007
Wil Sinclair
We would be creating our own XSL-FO processor? That might come in handy later, but it may be overkill for the task at hand. Basically, we would just be borrowing the doc structure of XSL-FO, but picking up a big liability: we would be tied to the formatting limitations of XSL-FO. Would there be any options if we ran in to such a limitation? AFAIK, XSL-FO doesn't have a lot of drawing formatting capability. Also, if we were to go this route, the first request would likely be "I don't like your processor, how do I use my own?," so I would think we'd need to support pluggable processors. Is there an alternative doc model out there? We should also be aware of this proposal in discussing this: http://framework.zend.com/wiki/display/ZFPROP/Zend_File_Convert