gen2brain / go-fitz

Golang wrapper for the MuPDF Fitz library
GNU Affero General Public License v3.0
369 stars 87 forks source link

add ability to get links for a page #73

Closed hudon closed 1 year ago

hudon commented 1 year ago

doc.Links(pageNum) will return a slice of Links present on the given page

gen2brain commented 1 year ago

Thanks, this is a nice addition. I am just not sure about the new type Link, can you make it so it just returns the string? Or maybe you think something else can be added to that new type?

hudon commented 1 year ago

Thanks for the quick review! And for a very useful library.

I typed it that way because I saw the struct from mupdf and wanted to map it to a Go struct:

typedef struct fz_link
{
    int refs;
    struct fz_link *next;
    fz_rect rect;
    char *uri;
    fz_link_set_rect_fn *set_rect_fn;
    fz_link_set_uri_fn *set_uri_fn;
    fz_link_drop_link_fn *drop;
} fz_link;

I only need the URI, but I figured someone in the future may want the rect, for example?

If you're not convinced, I can switch it to return []string. Let me know

gen2brain commented 1 year ago

Merged, thanks.