feat(sync): add estimated pages calculation for reflowable ebooks

Reflowable ebooks (EPUBs) don't have inherent page numbers since layout
depends on device settings. Add an EstimatedPages() function that converts
total character count to an estimated print page count using the industry
standard of 1800 characters per page.

This provides a consistent, device-independent page count for progress
display (e.g., "Page 89 of 196" for a reflowable EPUB), matching how
KOReader and similar readers handle the same problem.
This commit is contained in:
2026-04-24 14:02:28 -04:00
parent be4f89fdd2
commit 3bc6b0f477
+9
View File
@@ -253,3 +253,12 @@ func ParseProgressFromJSON(data []byte) (*ProgressData, error) {
func MarshalProgressToJSON(progress *ProgressData) ([]byte, error) {
return json.Marshal(progress)
}
const CharsPerPage int64 = 1800
func EstimatedPages(totalCharacters int64) int {
if totalCharacters <= 0 {
return 0
}
return int(totalCharacters / CharsPerPage)
}