Save Documents

Two methods allow saving of a document: 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
}