Split document based on page break and heading in output EPUB using Java

Hello,


I have a word-document which i try to get saved as epub, with sub-documents stored within the epub. The whole word document gets saved as a single html file within the epub zip.

Please see attached zip file which contains word and resulting epub file.

The code in question goes like this:
HtmlSaveOptions so = new HtmlSaveOptions();
so.setSaveFormat(SaveFormat.EPUB);
so.setEpubNavigationMapLevel(9);
so.setDocumentSplitHeadingLevel(3);
so.setDocumentSplitCriteria(DocumentSplitCriteria.PAGE_BREAK);
so.setTempFolder("/tmp/");

Hi there,


Thanks for your inquiry.

That setting has no effect when applied to your document because your document contains no explicit page breaks. Instead if you set the criteria to split at heading paragraphs it should work much better for you.

If you have any further queries, please let me know.

Thanks,

Hi!


In the code mentioned, i also use setDocumentSplitHeadingLevel(3), but yet there are no splitting in progress. I also tried changing it to 5 and 9 (as per some examples), yet no changes are seen.

Hi there,


That option controls up to which level of headings the document is split at, however in order to tell the engine to split at the headings you need to specify that in setDocumentSplitCriteria. Note that this properly is one that can be defined by bitwise flags, so to split at both you can use

DocumentSplitCriteria.PAGE_BREAK | DocumentSplitCriteria.HEADINGS

Thanks,

Tried that now and it works like charm!


Thanks for the help :slight_smile: