Skip to content
epub2pdf Convert

EPUB to PDF with page numbers

Most converters hand you a wall of text with nothing to navigate by. This one builds the contents page, numbers the pages, fills the bookmarks pane and puts the chapter title along the top.

Read in this tab. Never uploaded. Here's why that's true.

2-pass
contents numbering
Clickable
contents and outline
0
bytes uploaded

Four separate things, and they are easy to confuse

A book you can find your way around has four bits of navigation furniture in it. They do different jobs and they fail in different ways, so it helps to name them properly.

Page numbers. A number at the foot of every page. Sounds trivial. It is the thing an EPUB cannot have, because an EPUB has no pages until something decides how big a page is. Once you have chosen A4 or A5, the numbers become real and everything else can point at them.

The contents page. A printed page near the front listing every chapter with the page it starts on, dot leaders running across to the number. It prints. Hand someone the stack of sheets and it still works.

Bookmarks. The sidebar in your PDF reader. This is a separate structure stored alongside the pages, called the outline in the PDF specification, and it never prints. It is what makes a 400-page PDF navigable on a screen.

Running heads. The chapter title along the top of each page. Nobody notices them until they are missing and they are trying to find their place in a pile of loose paper.

Why the page numbers are correct

There is a small circularity here that most converters get wrong or avoid by not trying. The contents page has to list the page each chapter starts on. But the contents page is itself pages, sitting at the front, pushing everything after it further back. Write the numbers first and they are all wrong by however long the contents turned out to be.

So the book is laid out twice. The first pass sets every chapter and records where it landed. That tells us how many entries the contents needs and therefore how many pages it occupies. The second pass inserts it and shifts the numbers to match. For a book with a contents page that grows past a page boundary on the second pass, it runs again.

Easy way to check: open the PDF, look at the contents, pick the longest chapter, jump to the number printed next to it. You should land on the chapter opening, not near it.

Bookmarks, and where they hide

Bookmarks work in Preview, Acrobat Reader, Firefox, Chrome, Okular, Evince, PDF Expert and Documents. What varies is how far in they are buried. In macOS Preview the outline does not appear until you pick View, Table of Contents, and on phones it is usually two taps into a menu rather than a visible sidebar. Enough of a detour that people regularly conclude a PDF has no outline when it has a perfectly good one.

That patchiness is the reason the printed contents page is on by default as well as the bookmarks. Between the two, one of them survives whatever the reader happens to open it in, and the printed one survives being printed.

Where the chapter names come from

An EPUB usually carries its own table of contents. EPUB 3 books have a nav document; EPUB 2 books have a file called toc.ncx. Whichever is present is used, preferring the newer one, and the entries become both the contents page and the bookmark tree.

When a book has neither, which happens with files exported from writing tools, the headings in the text are used instead. That is right most of the time. It occasionally promotes something that was styled as a heading but was never a chapter, such as a dedication or a part title, and you will see it in the contents.

What this does not do

Cross-references inside the text are not clickable. The contents page links and the bookmarks both work. A "see chapter 12" in the middle of a paragraph does not, even where the EPUB had it as a link. It is on the list.

Footnotes run inline rather than sitting at the foot of the page they belong to. Proper foot-of-page footnotes need the layout to reserve space before it knows what will land there, which is a bigger change than it looks.

No index is generated. If the book has one, it converts as text, but its page numbers refer to whatever edition it was written for and will not match your PDF.

The full pipeline is written up if you want the detail, and reading a PDF on a screen covers which viewers make the outline easy to reach.

Questions

Does the contents page have real page numbers?

Yes. The book is laid out first, so by the time the contents page is written every chapter has a page it actually starts on. The numbers are printed with dot leaders and each line is a clickable link. Because adding the contents page shifts everything after it, the layout runs a second time and the numbers are corrected before the file is written.

What is the difference between the contents page and bookmarks?

The contents page is printed paper: it exists in the document, it prints, and it works if you hand someone a stack of sheets. Bookmarks are the PDF outline, a sidebar your reader app draws from data stored alongside the pages. They never print. Most people want both, so both are on by default.

Which apps show PDF bookmarks?

Preview on macOS (View, then Table of Contents), Adobe Acrobat Reader everywhere, Firefox and Chrome in their built-in viewers, Okular and Evince on Linux, and PDF Expert or Documents on an iPad. Support on phones is patchier, and the outline is often two taps into a menu rather than a visible sidebar, which is why people conclude a PDF has none.

Where do the chapter names come from?

From the EPUB's own navigation. EPUB 3 books carry a nav document; older EPUB 2 books carry an NCX file. Either is used, in that order. If a book has neither, the headings found in the text are used instead, which is usually right and occasionally picks up something that was never meant to be a chapter.

Can I turn the running heads off?

Yes, page furniture is a checkbox. It is worth leaving on for anything you print and worth turning off for a phone-sized page, where the header and footer eat a meaningful share of a small screen.