How do I create a TOC for ePub

I’m doing the following:

Dim builder As New DocumentBuilder(doc)
builder.InsertTableOfContents("\o ""1"" \h \z \u ""My Heading 1;1;My Heading 2;2""")
builder.InsertBreak(BreakType.PageBreak)

but if I look at the epub through digital edition, I see the table of contents as part of the first page.
when I click on table of contents I get nothing.
This is the screen shot of what I see, plus the doc, and the epub.

Hello,
Thank you for your request.
Try to use BreakType.SectionBreakNewPage instead BreakType.PageBreak. The same way I was able to navigate to other pages of the document with help the TOC. I also noticed that you are using version 9.8 of our product. We recommend you upgrade to the latest version of 10.0 you can download here.

Hi Ursula,
Thanks for your inquiry. The reason this happens is because the content in your first is laid out in a table. This means the first node in the first body of your document is a table. The builder will attempt to insert TOC into the first paragraph, which in your case is the first paragraph inside the table.
To fix this I suggest inserting a paragraph into the body and then inserting the TOC into this. Please see the code below.

Document doc = new Document("DA-BooktempShortVersion.doc");
doc.FirstSection.Body.PrependChild(new Paragraph(doc));
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertTableOfContents("\\o \"1\' \\h \\z \\u \"My Heading 1;1;My Heading 2;2\"");
doc.Save("Document Out.docx");

Thanks,

That makes sense.

Why would in this case the page numbers shown like this. It should be 1,2, 3, 4

DRACULA …2
Chapter One…1
Chapter TWO…2
Chapter Three …3

How would I change the style for this toc. It appears all in blue bold underline?

thanks.

Hi
Thanks for your request. Unfortunately, currently there is no way to change appearance of TOC items upon exporting to HTML based formats. We will consider adding an option to preserve original formatting of TOC upon exporting to HTML. Your request has been linked to the appropriate issue. We will let you know once it is resolved.
Best regards,

And you mean epub as well?
If I create the TOC in the word doc itself, how do I get the TOC to show when I click on the Table of Contents in Calibre or in Digital Editions?

It seems that Calibre and Digital Editions format the book totally different.
What are the guidelines to make the word doc look good in both readers.

thanks.

Hello,
Thank you for your request.
Yes we had in mind as well and epub. Please try to rename the extensiion of file into zip archive. Open and you will see that inside a lot of html files. As already said Andrey, we can not change the style of TOC for html documents. About the fact that the document looks different due to the fact that the markup html document occurs differently on devices with different screen resolution.

Not sure we are understanding each other.

I’m already aware that epub is a zip file containing html files and other files.

If I set the TOC correctly in my word doc, and I convert to epub, would the TOC appear under the Table of Contents of Calibre or Digital Editions? Or are you saying that there’s no way that can work even if the word document is correct.

How can we make it look right for all devices. Do you have any guidelines or some documentation to get it to look right?

Most likely in your case, you first need to edit your original document. I see that your document already has TOC. As I see, the document is formatted is very specific. Try to artificially mark your pages with PageBreaks. In general, without pre-processing document, make the document was the same on all devices, perhaps impossible.

Hi Ursla,
Thanks for your inquiry.
Do you mean the navigation pane found on the left side of Digital Editions? This section is populated using paragraphs styled with Heading styles in the document. The range of headings exported is defined using the EpubNavigationMapLevels property. Please see the code below.

HtmlSaveOptions htmlOptions = new HtmlSaveOptions(SaveFormat.Epub);
htmlOptions.EpubNavigationMapLevel = 5;

Regarding the different layouts, it is hard to get a flow format like EPUB to look exactly the same across a variety of different devices. However if you are able to paste comparsion images of how it appears on both devices then we can suggest some further ways to refactor your document to preserve layout.
Thanks,

I was using

HtmlSaveOptions htmlOptions = new HtmlSaveOptions(SaveFormat.Epub);
htmlOptions.EpubNavigationMapLevel = 1

Since I want to grab the first heading only, but I still don’t see the Table of Contents.

I’ve attached the word doc, the screen shot regarding the table of contents, and the screen shot from calibre showing how the pages are presented together instead of each on it’s own page like digital editions show.

Hi Ursula,
Thanks for your inquiry.
The reason why no titles are appearing in the navigation pane is because no paragraphs are formatted with the Heading styles in your document. Please see the screenshot below, the paragraphs you want to appear in the navigation pane must be formatted with the Heading 1 style.
``
Regarding the content flowing together on Calibre, I can see what you mean. I will log this for further investigation. In the mean time, as Viktor suggested, you should beable to avoid this by using explict page breaks (insert a page break at the end of each page).
I’m afraid we currently don’t have any documentation presenting guidelines on how to format documents to they are laid out properly in HTML. However, this is a good topic for the documentation. I have also logged your request for this.
If I can help with anything else, please feel free to ask.
Thanks,

The issues you have found earlier (filed as WORDSNET-4789) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-4769) have been fixed in this Aspose.Words for .NET 23.3 update also available on NuGet.