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

Free Support Forum - aspose.com

How to write the HtmlDocument object into byte stream

I am parsing the html content using HtmlDocument object, how do I write it to byte stream. In other cells and pdf product, they provide api to save it to outputstream. But I don’t see any such api in HtmlDocument. Only api I see is document.save(file)


The feature request as HTMLJAVA-580 has been logged in our issue tracking system for your requirements. We will investigate its feasibility and let you know as soon as it is implemented. Please be patient and spare us some time.

We are sorry for the inconvenience.

Is it possible to get a string containing an HTMLDocument contents?


Do you want to get complete HTML string from a .html file or there is some specific format in which would you need to extract it? Would you kindly share a sample HTML document along with details of expected output. We will test the scenario in our environment and address it accordingly.

I need to open HTML file, make some changes and get the resulting HTML as a string.


We are checking your requirements and will get back to you shortly.


You can get HTML as string by using following code snippet:

public void printHtml() {
        HTMLDocument htmlDocument = createHTMLDocument();

Furthermore, please check following article(s) in API documentation to edit the HTML document:

Thanks, it works!

1 Like