10. A non-transitory machine readable medium storing a program which when executed by at least one processing unit, defines a reading order through a plurality of primitive areas of a document page, the program comprising sets of instructions for: sorting the plurality of primitive areas into a sorted sequence of primitive areas based on a first sorting criteria that compares start points of the primitive areas within the document page, the sorted sequence comprising a first primitive area and a second primitive area subsequent to the first primitive area in the sequence; comparing the first primitive area and the second primitive area according to a second sorting criteria that compares a location of a start point of the first primitive area relative to a region preceding the second primitive area and a region following the second primitive area; transposing the first and second primitive areas in the sorted sequence when the start point of the first primitive area is in the region following the second primitive area; and generating an ordered list to define the reading order through the primitive areas based on the transposed sequence of primitive areas.
10. A non-transitory machine readable medium storing a program which when executed by at least one processing unit, defines a reading order through a plurality of primitive areas of a document page, the program comprising sets of instructions for: sorting the plurality of primitive areas into a sorted sequence of primitive areas based on a first sorting criteria that compares start points of the primitive areas within the document page, the sorted sequence comprising a first primitive area and a second primitive area subsequent to the first primitive area in the sequence; comparing the first primitive area and the second primitive area according to a second sorting criteria that compares a location of a start point of the first primitive area relative to a region preceding the second primitive area and a region following the second primitive area; transposing the first and second primitive areas in the sorted sequence when the start point of the first primitive area is in the region following the second primitive area; and generating an ordered list to define the reading order through the primitive areas based on the transposed sequence of primitive areas. 14. The non-transitory machine readable medium of claim 10 , wherein each of the start points comprises a vertical coordinate and a horizontal coordinate, wherein the first sorting criteria compares the vertical coordinates of the start points.