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:
@@ -253,3 +253,12 @@ func ParseProgressFromJSON(data []byte) (*ProgressData, error) {
|
|||||||
func MarshalProgressToJSON(progress *ProgressData) ([]byte, error) {
|
func MarshalProgressToJSON(progress *ProgressData) ([]byte, error) {
|
||||||
return json.Marshal(progress)
|
return json.Marshal(progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CharsPerPage int64 = 1800
|
||||||
|
|
||||||
|
func EstimatedPages(totalCharacters int64) int {
|
||||||
|
if totalCharacters <= 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return int(totalCharacters / CharsPerPage)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user