Advanced Function Presentation has been developped by IBM over many
years. From 2006 AFP has been "opened" to a multivendor consortium. See
the details at: http://www.afpcinc.org
AFP is actually more than a file format. IBM called it an
architecture, that specifies, among other, a set of file formats. See
http://en.wikipedia.org/wiki/Advanced_Function_Presentation
The
main specification concerns MO:DCA.
It takes some time to get used to the jargon. To make things worst, the specification uses the expression "AFP environment" to design a set of former IBM products (software, spooler and printers).
AFP is made of "Structured Fields" (SF), organised in objects. For example, a page is made of a "Begin Page" SF, followed by some SF's, followed by a "End Page" SF.
Inside the Structured Field, there are fixed parameters (fixed: with a fixed length), and/or triplets. Fixed parameters and triplets can be grouped in Repeating Groups.
afppowertools is essentialy a "push" parser that loops over the structured fields. You must register some handlers (callbacks) before you start the parser.