• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

The Rendering Fidelity of Footnotes

Ranch Hand
Posts: 714
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The aim of this article is to reveals some important facts about how Aspose.Words handles and support rendering of footnotes and endnotes when rendering documents to PDF, XPS or printing. The article will also explain how Microsoft Word handles some tricky layouts and even discloses some obscure flaws. It also explains the reasons why it taking so long for the Aspose.Words team to support footnotes. We hope this article would reveal some interesting points to Aspose.Words customers & developers.

The most obvious objective of Aspose.Words layout engine is to produce similar result to Microsoft Word. Our team has spent a lot of time in figuring out how Microsoft Word formats a document into pages. No doubt Footnotes are very important for us because many of our customers have requested for this feature. We hope this article would reveal some interesting points to Aspose.Words customers who are waiting for footnotes to be supported or to any other developer whoever pondered about document layout.

What Aspose is Team has Done so Far

The new release of Aspose.Words for .NET supports rendering of footnotes to some extent but there is still room for a lot to be done. With this release it would be possible to render some simple documents but not very complex one. Looking to the high demand from our customers our team has decided, that it is better to include it now rather than later.
Some of the limitations are:
- Only footnotes are rendered. Endnotes are not rendered.
- Footnotes are rendered immediately below text (not at the bottom of the page)
- Wrapping of long footnotes to next page is not supported. The text of the footnote could be truncated.
- Occasionally the text of the footnote will not appear.
More complete support is coming in the next version, estimated in May 2010.

Magic Footnotes
Everybody that is using Microsoft Word must have some idea about footnotes and endnotes, below are some important points that would give our readers more clear understanding of footnotes and endnotes functionality.
- Footnote or endnote consists of two parts. One part is a reference mark in the main text story of the document. The other part is the content of the footnote or endnote which is typically rendered at the bottom of the page or at the end of the document.
- References are continuously numbered, but can use custom marks or skip numbers.
- There are also three types of delimiters used to separate main text from the footnote/endnote text. They are separator, continuation separator and continuation notice.
- Footnote/endnote text can wrap from one column to another and can occupy one or more pages at the end of a section.
- There are two types of locations for footnote text and two types for endnote text.
- Footnote/endnote numbering and location can be specified per section in a document.
When our team starting to analyze this feature I knew that implementation challenge wouldn’t be technical but rather logical. The layout model of the document (it was adapted from Aspose.Editor before it was discontinued) already provides more functionality than required by Aspose.Words rendering. It already keeps track of all stories in the document but until recently footnotes story was ignored.
With this kind of attitude our team was hoping to prototype Aspose.Words code in a few hours and started to create small, but tricky test documents in Microsoft Word and tried to push its layout engine into a corner and that’s where the “magic” begun.

Magic 1: Non-trivial ordering of footnotes

While table fits into one page footnotes flow according to the logical order of the references in the main text story, from 1 to 9. The second screenshot has same numbers for references but content is now ordered differently. There is no error and “yes” there are two “5” footnotes. This is how Word 2007 renders this case (not surprising though). Let’s ignore the bug for now but focus on the ordering issue.
Technically, a footnote story can be represented as a linked list of runs that is “1 One¶2 Two¶…9 Nine¶”. In Microsoft Word you can move caret from one footnote to another and using VBA you can query current position in the story which returns increasing integer. Word’s layout engine uses this order to pick a next portion of content to be flowed into a geometrical container. However, as we’ve seen this no longer works for footnotes since “seven” is rendered after “nine”.

Magic 2: Column Balancing with Footnotes
The second thing is balancing of text columns. If a section ends with a “section break continuous” break and it has two or more columns then the content will be balanced between last group of columns of this section to minimize height of this group. Microsoft Word will include the height of the footnotes/endnotes into the column and balancing shall account for it.
Right, a bug again. Endnote “C” is overlapped by content of a second section on the page. Ignore the bug for now, but still the issue is that the column was designed to aggregate main text story content, however, as we’ve seen content of footnote/endnote stories is also flowed into it and balancing must handle this properly.

Magic 3: Wrapping to Next Page
Third and last for this post is picking the right positions to wrap footnote and main text content. Our initial thoughts were that Microsoft Word flows main text story content and footnotes in parallel. We thought that it attempts to flow footnote content as soon as a reference is flowed into the column. However the next example made us anxious.
If the idea was correct, then Microsoft Word would flow both 1st and 2nd footnotes right after first two lines of the main text story are flowed into the column, which means that 2nd footnote would fit on the first page completely and last two lines of the paragraph would be wrapped to the next column. However this doesn’t happen. Do you know why?
You need to take paragraph rules into account. They are working in both main text and footnote text. There are also rules which try to keep the reference and content on the same page, rules about sharing of page by footnotes and endnotes, separator overflows, and hopefully you’ll get an idea of why it takes so long to implement layout of footnotes/endnotes the way Microsoft Word does it.

If you have something to say we’d be more than glad to hear it.

Overview: Aspose.Words for .NET

Aspose.Words is a word processing component that enables .NET applications to read, write and modify Word documents without using Microsoft Word. Other useful features include document creation, content and formatting manipulation, mail merge abilities, reporting features and support of DOCX, DOC, WordprocessingML, HTML, XHTML, TXT and PDF formats (requires Aspose.Pdf). It supports both 32-bit and 64-bit operating systems. You can even use Aspose.Words for .NET to build applications with Mono.

More about Aspose.Words for .NET

- Homepage Aspose.Words for .NET:
- Features overview Aspose.Words for .NET:
- Online documentation of Aspose.Words for .NET:
- Post your technical questions/queries to Aspose.Words for .NET :
- Receive notifications about latest news and supported features by subscribing to Aspose.Words for .NET :

Contact Information
Suite 119, 272 Victoria Avenue
Chatswood, NSW, 2067
Aspose - The .NET and Java component publisher
Phone: 888.277.6734
Fax: 866.810.94651
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic