• Robert Knight's avatar
    Replace `document.title` as a fallback for title in PDFs · 40eaf5c9
    Robert Knight authored
    Replace the usage of `document.title` as a way to get the document title
    if the PDF has no embedded title in either its _document info
    dictionary_ or _metadata stream_.
    
    In top-level frames using `document.title` (where `document` is the
    global HTML document, not the PDF) works because PDF.js sets the title
    based on the first non-empty value from:
    
     1. The embedded title
     2. The filename from the `Content-Disposition` header
     3. The last segment of the URL's path (eg. "test.pdf" in
        "https://example.com/test.pdf")
    
    When PDF.js is embedded in an iframe however, it does not set
    `document.title` by default. As a result, documents were ending up in
    Hypothesis with a generic "PDF.js viewer" title.
    
    This commit implements (roughly) the same logic that PDF.js uses to
    determine the value used to set `document.title`, in the case where the
    PDF has no embedded title. This means implementing steps (2) and (3)
    from the above list. The `Content-Disposition` filename is not exposed
    as a public property on `PDFViewerApplication`, so
    `PDFMetadata#getMetadata` was refactored to call the
    `pdfDocument.getMetadata` instead.
    
    Fixes https://github.com/hypothesis/client/issues/3372
    40eaf5c9
Name
Last commit
Last update
..
anchoring Loading commit data...
components Loading commit data...
config Loading commit data...
integrations Loading commit data...
test Loading commit data...
util Loading commit data...
.eslintrc.js Loading commit data...
adder.js Loading commit data...
annotation-counts.js Loading commit data...
annotation-sync.js Loading commit data...
bucket-bar.js Loading commit data...
cross-frame.js Loading commit data...
features.js Loading commit data...
frame-observer.js Loading commit data...
guest.js Loading commit data...
highlighter.js Loading commit data...
icons.js Loading commit data...
index.js Loading commit data...
notebook.js Loading commit data...
range-util.js Loading commit data...
selection-observer.js Loading commit data...
sidebar-trigger.js Loading commit data...
sidebar.js Loading commit data...
toolbar.js Loading commit data...