“Only 25% of our incoming EPUB files contain page numbers, and until we can get this number much higher, academic libraries and users will not adopt EPUB at scale.”
opened 06:38PM - 02 Nov 15 UTC
enhancement
Needs Spec
Add a page-list nav to exported EPUB containing the page numbers of the PDF if a… PDF is exported at the same time.
Such a page-list nav is recommended for EPUB by the IDPF:
"If an EPUB has a print counterpart, or is derived from a print source, the pagination should be retained and included in the publication for cross-referencing."
http://www.idpf.org/accessibility/guidelines/content/nav/pagelist.php
http://www.idpf.org/accessibility/guidelines/content/xhtml/pagenum.php
If block elements inside the html files that are fed to EPUB and PDF workflow all contain unique ids then the prince box tracking API can be used to output the ingredients for the page-list nav.
<code>
Prince.trackBoxes = true;
Prince.addEventListener("complete", makePageList, false);
function getFirstElement(pageNum, box)
{
if (box.element && box.element.getPrinceBoxes()[0].pageNum == pageNum &&
box.element.id)
{
return box.element;
}
```
for (var i = 0; i < box.children.length; ++i)
{
var curr = getFirstElement(pageNum, box.children[i]);
if (curr) return curr;
}
return null;
```
}
function makePageList()
{
for (var i = 0; i < PDF.pages.length; ++i)
{
var page = PDF.pages[i];
var pageNum = i + 1;
```
var curr = getFirstElement(pageNum, page);
if (curr)
{
Log.data(pageNum, curr.id);
}
else
{
Log.warning("page: "+pageNum+", no element found");
}
}
```
}
</code>