The JSON serializable object that describes a document.
JSON serializable object that describes a document.
DocumentDescriptor is a class that holds JSON data that describes a document. This data can be obtained from any document using Document.CreateDocumentDescriptor and the document can then be disposed. At a later time, DocumentFactory.Create can be called with this descriptor object set in CreateDocumentOptions.Descriptor to regenerate the original document. Document.UpdateFromDocumentDescriptor can be used to update an existing document from a descriptor.
This technique is used by LEADTOOLS Documents Web Service as follows:
The user creates a new document using JavaScript.
The document is manipulated at the JavaScript side, for example, pages are added or removed and the document could be set in the document viewer for display
During this whole process, the document exists only on the client side - it is not save to the server cache.
When ready, the user calls DocumentFactory.saveToCache
from the JavaScript code. Here, the JavaScript toolkit library will create
a DocumentDescriptor object and send it to the Documents service method SaveToCache
The service will try first to load the document from the cache, if it does not exist (when this is the first call to save this document), it will then use DocumentFactory.Create with CreateDocumentOptions.Descriptor set to the object passed into the request by JavaScript. If the document exists, then Document.UpdateFromDocumentDescriptor is called to update the document object from the JavaScript object in case it has changed (subsequent calls to Document.SaveToCache for this document).
Finally, Document.SaveToCache is called to save the updated document into the cache
DocumentId is not used if Descriptor is not null. Instead, the document creation data along with its ID is stored in the DocumentDescriptor object set in the method.
For an example, refer to DocumentFactory.Create.