Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Page number is always 0 in Document's outlines() method #68

Open
LazyGeniusMan opened this issue May 19, 2023 · 1 comment
Open

Comments

@LazyGeniusMan
Copy link

LazyGeniusMan commented May 19, 2023

I'm trying to get table of content data of epub files with this code:

fn main() {
    use mupdf::{Document, Outline};

    let doc: Document = Document::open("C:\\Users\\LazyGeniusMan\\Downloads\\mupdf\\test.epub").unwrap();
    let toc: Vec<Outline> = doc.outlines().unwrap();
    for i in toc {
        println!("{:#?}", i)
    }
}

but the output of the page is always 0 like this:

Outline {
    title: "Cover",     
    uri: None,
    page: Some(
        0,
    ),
    down: [],
    x: 0.0,
    y: 0.0,
},
...
Outline {
    title: "5 Centimeters per Second",
    uri: None,
    page: Some(
        0,
    ),
    down: [
        Outline {
            title: "Chapter One: Tale of Cherry Blossoms",
            uri: None,
            page: Some(
                0,
            ),
            down: [],
            x: 0.0,
            y: 0.0,
        }
        ...
...
}

But when I try using PyMuPDF in python with this code:

import fitz

doc = fitz.Document('C:\\Users\\LazyGeniusMan\\Downloads\\mupdf\\test.epub')
toc = doc.get_toc()
for i in toc:
    print(i)

it can show the correct page number index with format [level, title, page number] like this:

[1, 'Cover', 1]
[1, 'Title Page', 2]
[1, 'Copyright', 3]
[1, 'Table of Contents', 5]
[1, '5 Centimeters per Second', 7]
[2, 'Chapter One: Tale of Cherry Blossoms', 8]
[2, 'Chapter Two: Cosmonaut', 28]
[2, 'Chapter Three: 5 Centimeters per Second', 50]
[2, 'Afterword', 79]
[2, 'Essay', 81]
[1, 'Children Who Chase Lost Voices', 84]
[2, 'Chapter One', 85]
[2, 'Chapter Two', 91]
[2, 'Chapter Three', 98]
[2, 'Chapter Four', 101]
[2, 'Chapter Five', 116]
[2, 'Chapter Six', 124]
[2, 'Chapter Seven', 131]
[2, 'Chapter Eight', 140]
[2, 'Chapter Nine', 144]
[2, 'Chapter Ten', 150]
[2, 'Chapter Eleven', 157]
[2, 'Chapter Twelve', 160]
[2, 'Chapter Thirteen', 169]
[2, 'Afterword', 172]
[1, 'Yen Newsletter', 174]
@messense
Copy link
Owner

Sorry, this project is not actively maintained at the moment, but I'm happy to accept pull requests to fix this if anyone is up for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants