I figured out a way to do this. It
s not a perfect solution, but it works!
The idea is that I convert a ePub file to a Word file using calibre. I then use the Macros function of the Microsoft Word to insert the calculated "page numbers" into the text. Finally, I convert the modified Word file back to a ePub file using calibre again.
Here is the code if you are interested in. Please google it if you do not know how to use the Macros function. It's simple.
Modify the code to suit your purpose:
- In this code, I define a page has 300 word. You can change it to whatever you want.
- The page number looks like "8 ". You can change it to other format like "(8)"...
Application.ScreenUpdating = False
Dim Rng As Range, i As Long, j As Long, k As Long, w As Long
Const l As Long = 300 'Word per page, now 300
Set Rng = .Range(0, 0)
For i = 1 To .Words.Count Step l
Rng.MoveEnd wdWord, l
.InsertBefore "__" & Round(i / l) + 1 & "__ "
Application.ScreenUpdating = True