Save Documents
Two methods allow saving of a document:
- OpenedDocument.save: saves the current state of the document to the (temporary) file associated with the document
- OpenedDocument.getW2MLData: gets the current state of the document as W2ML String, which can be saved to whatever destination is applicable
Usually, there is no need to call the save method, as renderer commands use the (most recent) document status kept in memory and persisting document data at the end of processing must be handled on client side (depending on the DocumentAccessProvider).
So, the recommended pattern for saving a file is
String w2mlString = "";
try (OpenedDocument document = Renderer.openDocument("DSN", new TmpCopyFromString(w2mlString, W2MLDocumentType.class))) {
// some document processing...
String w2mlUpdated = document.getW2mlData();
Files.write(Paths.get("destination.w2ml"), w2mlUpdated.getBytes());
}
catch (RendererException e) {
// Exceptions thrown during opening, rendering, saving ...
}
catch (Exception e) {
// Exception thrown during closing
}