Using Document Objects

A Document must be created and used on the same thread that created the parent session.

Changing session configuration options can change the data that is returned by methods of a document object, even if you created the document object before changing the configuration.

Consider the following example. You have a document with embedded images but no subfiles and you run the following code:

Copy
try (Document myDoc = session.open(inputFilePath)) {
     myDoc.subfiles().size(); // Returns 0
     
     session.config().extractImages(true);
     
     myDoc.subfiles().size(); // Returns 3
}

This example shows that the extractImages session configuration option must not be changed while iterating over subfiles - because the list of subfiles would be invalidated. OpenText recommends disposing all objects created by open Document objects before changing the session configuration.