By default GroupDocs.Viewer saves output results to the local disk, but we also provide a way to save output results into a stream.
There are three interfaces that we can utilize:
FileStreamFactory - defines the methods that are required for instantiating and releasing output file stream.
PageStreamFactory - defines the methods that are required for instantiating and releasing output page stream.
ResourceStreamFactory - defines the methods that are required for creating resource URL, instantiating and releasing output HTML resource stream.
Let’s say that instead of saving rendering results to the local disk we want to have all the output file or output files in form of stream or list of streams.
What we need to do is to implement one or two of the interfaces listed above.
When rendering into PDF we have to implement FileStreamFactory interface and pass implementation into PdfViewOptions constructor
classMemoryPageStreamFactoryimplementsPageStreamFactory{privatefinalList<ByteArrayOutputStream>_pages;publicMemoryPageStreamFactory(List<ByteArrayOutputStream>pages){_pages=pages;}publicByteArrayOutputStreamcreatePageStream(intpageNumber){ByteArrayOutputStreampageStream=newByteArrayOutputStream();_pages.add(pageStream);returnpageStream;}publicvoidclosePageStream(intpageNumber,OutputStreampageStream){//Do not release page stream as we'll need to keep the stream open
}}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.