Exporting Word with collapsed document parts


we use a commerical Aspose Words for java licence to export Word files to HTML.
Some customer documents have collapsed text like described here:

In the resulting HTML file the collapse switch is missing. Is this feature supported in Aspose Words and how would we enable this?

The corresponding code for the transformation in our application is:

HtmlSaveOptions format =
          new HtmlSaveOptions(SaveFormat.HTML);
new Document(path).save(folder.getAbsolutePath() +  File.separator + "out.html", format);

I added an attachment for the input and output file.

test-collapse.docx.zip (494 Bytes)
test-collapse.docx (16,7 KB)

Best regards

Andreas Moll

@amoll This is expected behavior. If you convert the document to HTML using MS Word the output will be exactly the same. Collapsing content under heading is MS Word feature, not document feature.

Thank you for the quick answer. Could you please give me a hint to a code snippet on how we could find specific headings in the word document and mark them with custom html css properties so that we could implement this ourselves?

@amoll Heading paragraph are exported to HTML as H1-H6 tags. So you can simply used these tags to identify headings in the HTML document.

It is quite obvious that headings are exported as h1 - h6. But only some of the customer headings have the collapsed property. Can I identify these via the Aspose API and if so: Is there an easy way to mark them in a way that is persisted into the html?

@amoll Paragraphs with outline level specified have collapse button.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("This is colapsable");
builder.writeln("Some text");

So you can check paragraph outline level to determine such paragraphs.