NavigationMapLevel
HtmlSaveOptions.NavigationMapLevel property
Specifies the maximum level of headings populated to the navigation map when exporting to EPUB, MOBI, or AZW3 formats. Default value is 3
.
public int NavigationMapLevel { get; set; }
Remarks
The navigation map allows user agents to provide an easy way of navigation through the document structure. Usually navigation points correspond to headings in the document. In order to populate headings up to level N assign this value to NavigationMapLevel
.
By default, three levels of headings are populated: paragraphs of styles Heading 1, Heading 2 and Heading 3. You can set this property to a value from 1 to 9 in order to request the corresponding maximum level. Setting it to zero will reduce the navigation map to only the document root or roots of document parts.
Examples
Shows how to generate table of contents for Azw3 documents.
Document doc = new Document(MyDir + "Big document.docx");
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Azw3);
options.NavigationMapLevel = 2;
doc.Save(ArtifactsDir + "HtmlSaveOptions.CreateAZW3Toc.azw3", options);
Shows how to generate table of contents for Mobi documents.
Document doc = new Document(MyDir + "Big document.docx");
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Mobi);
options.NavigationMapLevel = 5;
doc.Save(ArtifactsDir + "HtmlSaveOptions.CreateMobiToc.mobi", options);
Shows how to filter headings that appear in the navigation panel of a saved Epub document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Every paragraph that we format using a "Heading" style can serve as a heading.
// Each heading may also have a heading level, determined by the number of its heading style.
// The headings below are of levels 1-3.
builder.ParagraphFormat.Style = builder.Document.Styles["Heading 1"];
builder.Writeln("Heading #1");
builder.ParagraphFormat.Style = builder.Document.Styles["Heading 2"];
builder.Writeln("Heading #2");
builder.ParagraphFormat.Style = builder.Document.Styles["Heading 3"];
builder.Writeln("Heading #3");
builder.ParagraphFormat.Style = builder.Document.Styles["Heading 1"];
builder.Writeln("Heading #4");
builder.ParagraphFormat.Style = builder.Document.Styles["Heading 2"];
builder.Writeln("Heading #5");
builder.ParagraphFormat.Style = builder.Document.Styles["Heading 3"];
builder.Writeln("Heading #6");
// Epub readers typically create a table of contents for their documents.
// Each paragraph with a "Heading" style in the document will create an entry in this table of contents.
// We can use the "NavigationMapLevel" property to set a maximum heading level.
// The Epub reader will not add headings with a level above the one we specify to the contents table.
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Epub);
options.NavigationMapLevel = 2;
// Our document has six headings, two of which are above level 2.
// The table of contents for this document will have four entries.
doc.Save(ArtifactsDir + "HtmlSaveOptions.EpubHeadings.epub", options);
See Also
- class HtmlSaveOptions
- namespace Aspose.Words.Saving
- assembly Aspose.Words