setPreviewStream(OutputStream preview);
The XML Server takes an XML document and an XSL template and processes the two to produce another document which could be in PDF, RTF, HTML, or plain text format. Normally, the XML Server will run a further command to print, or otherwise process, the document. However, you can instead direct the XML Server to return the document to your application server rather than process it further. This allows you to preview the document before printing it or just store the document in the database for later retrieval.
To preview a document, you must specify a preview stream when configuring the print stream object. After the XML Server has generated the PDF it will return it to the print stream object which will in turn write it to the stream specified as a parameter to the setPreviewStream method. This stream could be a simple string stream buffer or a file stream, whatever is required. If no stream is specified, the XML Server will assume that a preview is not required.
Once the print stream object is closed, the preview stream will contain the document and the application server can manipulate it in any way required. For example, it could be returned to the client application and displayed in an appropriate viewer of some kind.