How save HTMLDocument to MemoryStream?

Hi support,

I need to save my HTMLDocument to MemoryStream.
How can i save HTMLDocument to MemoryStream for further using?

Thanks,

@Kruzer

Please go through the articles about Output Streams in the public API documentation in order to save the HTMLDocument into memory stream.

@asad.ali Yeah, i checked it. But i not clearly understand how i can put HTMLDocument to Stream without saving it to HDD.
I need save raw HTMLDocument to stream without converting it to image.
Could you please provide example?

@Kruzer

We do not have a specific article describing this functionality. But here is an example of saving to custom output storage, which can be memory storage. HTMLDocument.Save | Aspose.HTML for .NET API Reference

It can be used like this:

        public void Run()
        {
            var doc = new HTMLDocument("text", String.Empty);
            var stor = new MemoryOutputStorage();
            doc.Save(stor);
        }

        internal class MemoryOutputStorage : IOutputStorage
        {
            public List<Stream> streams = new List<Stream>();

            public OutputStream CreateStream(OutputStreamContext context)
            {
                var stream = new MemoryStream();
                streams.Add(stream);
                return new OutputStream(stream, context.Uri);
            }

            public void ReleaseStream(OutputStream stream)
            {
                stream.Dispose();
            }
        }