Skip to content

Handle PDF anchor links, esp #page=N (currently false positives) #59

Description

@gwern

PDF readers support a variety of ways to link inside them similar to HTML pages: a foo.pdf#page=5 will link to page 5 of that PDF, or a defined anchor like a section (common in Arxiv PDFs), or comments etc. See "Parameters for Opening PDF Files". This dates back to sometime around or before 2005, and is supported by many (most?) PDF viewers, although it is not an official standard AFAICT. I find them extremely useful for discussing research papers (>170 unique instances on my site so far), to hyperlink people to the exact page with the relevant figure or table or section (just as linking to parts of HTML pages is useful).

Right now link-checker treats all such arguments as errors and invalid anchors to warn about. This is unfortunate and clutters up my results considerably with false positives - the pages are all correct, but it always treats them as errors.

It should handle PDF parameters more gracefully.

The full set of parameters is probably unnecessary (I have never seen many of them in the wild, and I doubt many readers beyond Adobe Acrobat support the more obscure ones like fdf for population form fields), but page, named anchors, zoom, and view are worth supporting. page could be checked simply by, on links which return a PDF MIME type, checking that the N is a whole number less than or equal to the number of pages in the PDF. (Any PDF tool/library should be able to tell you how many pages are in a PDF.) Alternately, if a link returns a PDF MIME type, one could just skip checking anchors entirely as being too much work to figure out how to analyze arbitrary PDFs to check anchor validity and out of scope.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions