Wednesday, August 18, 2010

A real AFP page...

So after much work and toil my AFP application is now working as a true AFP creation application.

Most of the previous work has been related to creation of Page Segments (PSEGs) which are images or graphic objects.  Work has been centered around creating images in this format, performing color transformations, and so on.

The creation of actual AFP pages is really not a large step beyond this but in terms of remade AFP it is nice to finally see months of work validated.  The remake system currently supports altering PSEGs and other AFP constructs in existing AFP files.

The thing I am currently interested in is creating AFP pages that use PSEG images - both as a way to work with new AFP pages and as a platform for my new PDF/AFP compression model.

So my first task was to figure out what the "simplest" valid AFP file might be with a single image.  It turns out not be be that complex.  Basically you can think of the file like this:

     (BEGIN_RESOURCE_GROUP rt='BRG' x='D3A8C6' name='LXG00000' )
     (INSERT  id='821321_XXXX' /)
        (END_RESOURCE_GROUP rt='ERG' x='D3A9C6' name='LXG00000' /)
      (/BEGIN_RESOURCE_GROUP)

      (BEGIN_DOCUMENT rt='BDT' x='D3A8A8)
          (BEGIN_PAGE rt='BPG' x='D3A8AF')
            (BEGIN_ACTIVE_ENVIRONMENT_GROUP rt='BAG' x='D3A8C9' /)
          (MAP_PAGE_SEGMENT rt='MPS' name001='821321  ' x='D3B15F'/)
          (PAGE_DESCRIPTOR rt='PGD' XpgBase='00' YpgBase='00' XpgUnits='14400' YpgUnits='14400' XpgSize='11880' YpgSize='15840'  x='D3A6AF'/)
              (END_ACTIVE_ENVIRONMENT_GROUP rt='EAG' x='D3A9C9' /)
            (/BEGIN_ACTIVE_ENVIRONMENT_GROUP)
        (INCLUDE_PAGE_SEGMENT rt='IPS' x='D3AF5F' name='821321  ' XpsOset='400' YpsOset='700' /)
        (INCLUDE_PAGE_SEGMENT rt='IPS' x='D3AF5F' name='821321  ' XpsOset='800' YpsOset='1500' /)
            (END_PAGE rt='EPG' x='D3A9AF' /)
          (/BEGIN_PAGE)
        (END_DOCUMENT rt='EDT' x='D3A9A8' /)
      (/BEGIN_DOCUMENT)


The file consists of two parts (using simple non-XML XML so blogger won't choke): a resource which is the image to display and a document with a single page that displays that image.  The image is actual inserted from another AFP file (which we will talk about in another post) - but basically its the wholesale insertion of an AFP PSEG.  This resource could already be stored on the printer as a reusable object but we include it to make the AFP file completely self defining.  The PSEG has a name associated with it which is used by subsequent AFP to identify it.

The AFP document is quite straightforward and consists of a BEGIN/END document pair of AFP records.  Inside this pair is a BEGIN/END page to define the actual page.

In AFP an environment group (here enclosed by a BEGIN/END environment pair) appears immediately after the BEGIN page definition to describe the layout (height, width, resolution, included resources, and so on) of the page.  In this case two AFP records do this: a page descriptor (PGD) and a map page segment (MPS).

The page content is simply to include page segment records (IPS) that reference the image by name and indicate a position on the page to place it.

1 comment:

  1. Aw, this was a very nice post. In concept I would like to put in writing like this moreover – taking time and actual effort to make a very good article… however what can I say… I procrastinate alot and under no circumstances appear to get something done.
    afp viewer online

    ReplyDelete