From 44ec2f496ac9481f374d066d68b3d97ac9cd63bc Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 24 Apr 2026 14:02:28 -0400 Subject: [PATCH] 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. --- internal/sync/progress.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/sync/progress.go b/internal/sync/progress.go index e67834c..63730e9 100644 --- a/internal/sync/progress.go +++ b/internal/sync/progress.go @@ -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) +}