We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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?



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?


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. https://reference.aspose.com/html/net/aspose.html/htmldocument/save/#save_1

It can be used like this:

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

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

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

            public void ReleaseStream(OutputStream stream)