1. A non-transitory machine readable medium storing a program for execution by at least one processing unit, the program comprising sets of instructions for: receiving a document having a first format, the document stored as a stream representation comprising an ordered content stream and an object representation comprising a set of object nodes arranged in a tree structure, the object nodes referencing ranges of indices in the content stream; and converting an identified range of the document into a new format by recursively traversing the tree structure to identify nodes referencing indexes within the identified range and converting the identified nodes to the new format.