1. A computer readable medium storing a computer program which when executed by at least one processor analyzes a document that comprises a plurality of primitive elements, the computer program comprising sets of instructions for: identifying boundaries between sets of primitive elements; identifying regions bounded by the boundaries; and defining a structured document based on the regions and the primitive elements.