Skip to content

Conversation

@ginnyTheCat
Copy link
Collaborator

@ginnyTheCat ginnyTheCat commented May 28, 2025

Fix #68 by providing more information inside Outline by using the new LinkDestination struct and adding page_number to Location (which is what #68 is looking for).

The naming isn't great as there is page and page_number but i couldn't come up with anything better and that is what mupdf calls them themselves. I added a doc comment to clarify things. If somebody has a better idea for a name I would be more than welcome to change it.

This changes the output of .outlines() on a from, for example

Outline {
    title: "Copyright",
    uri: None,
    page: Some(
        0,
    ),
    down: [],
    x: 0.0,
    y: 0.0,
}

to

Outline {
    title: "Copyright",
    uri: Some(
        "OEBPS/Text/copyright.xhtml",
    ),
    dest: Some(
        LinkDestination {
            loc: Location {
                chapter: 23,
                page: 0,
                page_number: 186,
            },
            kind: XYZ {
                left: Some(
                    0.0,
                ),
                top: Some(
                    0.0,
                ),
                zoom: Some(
                    0.0,
                ),
            },
        },
    ),
    down: [],
}

@ginnyTheCat ginnyTheCat changed the title Return more information for Locations Return more information for outlines May 29, 2025
@ginnyTheCat ginnyTheCat marked this pull request as ready for review May 29, 2025 00:08
Copy link
Owner

@messense messense left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to merge after addressing minor issues.

@ginnyTheCat ginnyTheCat merged commit 2b829d8 into messense:main May 29, 2025
14 checks passed
@ginnyTheCat ginnyTheCat deleted the page_number branch May 29, 2025 02:42
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

Successfully merging this pull request may close these issues.

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

2 participants