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

Feature Request: Support hyperlinks in Document Outline #5089

Closed
nibblesnbits opened this issue Jul 25, 2014 · 23 comments
Closed

Feature Request: Support hyperlinks in Document Outline #5089

nibblesnbits opened this issue Jul 25, 2014 · 23 comments

Comments

@nibblesnbits
Copy link

Some PDFs I'm displaying with the viewer contain items in the document outline that, when rendered in Adobe Reader (haven't checked others), are actually hyperlinks. Would it be possible to support this in pdf.js? I'm looking at readDocumentOutline in obj.js right now and found what will hopefully lead me in the right direction, but if I'm off track let me know and I'll see if I can make the changes myself.

@timvandermeij
Copy link
Contributor

@wtfsven Please provide a link to a test document. I'm not entirely sure what you mean.

@nibblesnbits
Copy link
Author

@timvandermeij
Copy link
Contributor

Thank you for reporting this. It seems like this PDF is abusing the document outline view, but perhaps it's something that's hidden in the PDF specification...

@Snuffleupagus
Copy link
Collaborator

This sounds like a duplicate of #3214.

@nibblesnbits
Copy link
Author

This "abuse" is fairly common in my experience. I'll be doing my own research in the mean time.

@Rob--W
Copy link
Member

Rob--W commented Jul 25, 2014

http://www.nuveen.com/Home/Documents/Viewer.aspx?fileId=45693 's document outline does not have any apparent effect in PDF.js. When I open the document with Okular on Linux, clicking on an item in the outline results in one of the following URLs being opened in Chromium:
http://www.nuveen.com/Home/Documents/Default.aspx?fileId=45702
http://www.nuveen.com/Home/Documents/Default.aspx?fileId=45707

@yurydelendik
Copy link
Contributor

Indeed, the outline contains hyperlink instead of destinations (except last one):

screen shot 2014-07-25 at 2 53 24 pm

@nibblesnbits
Copy link
Author

Ok, so after some mucking around I've devised a temporary solution for anyone who needs it. It's a bit of a hack, but in readDocumentOutline in obj.js, (therefore in pdf.worker.js after a build), change the function to read:

var dest = outlineDict.get('A');
if (dest) {
    if (dest.has('URI')) {
        dest = dest.get('URI');
    } else {
        dest = dest.get('D');
    }
} else if //....

Then you can check in viewer.js, in bindItemLink...

if (typeof item.dest === "string" && /https?:/.test(item.dest)) {
    domObj.href = item.dest;
} else {
    domObj.href = PDFView.getDestinationHash(item.dest);
    //...

and go from there.

@kvk123456
Copy link

is there any fix for this issue in next available release?

@timvandermeij
Copy link
Contributor

This issue is related to #3214.

@kvk123456
Copy link

Since 3214 also closed can someone please answer me

Any resolution for this? can you please let us know the hyperlink issue in bookmark will be fixed in next release?

@Snuffleupagus
Copy link
Collaborator

I'm attaching the PDF file from issue #3214 here, as an additional example: bookmark-unsupported-features.pdf.

@timvandermeij
Copy link
Contributor

@kvk123456 As far as I know nobody is working on this. If someone would like to fix this, feel free to submit a pull request. We are just closing the other issues because they are duplicates of this one.

@Rob--W
Copy link
Member

Rob--W commented Dec 21, 2015

FYI, I developed a patch (not published) that recovers a missing outline from marked content (#6269). It does not work for many documents (because marked content is not that common), so I stopped working on it.

EDIT: Disregard this comment, I misread. I thought that the outline was missing, but this issue is actually asking about supporting hyperlinks in an existing outline.

@Snuffleupagus
Copy link
Collaborator

Here's a quick, sort of hacky, patch that adds basic support for URLs in the outline (I don't know if it's in good enough shape to bother with submitting a PR): Snuffleupagus@f292028.

@kvk123456
Copy link

when is the next release, whiich will have this fix?

@gsampath127
Copy link

The code is working when we the open pdf from local system.
When the pdf document is opened as query string to the viewer. The issue still exists.
Please suggest any better solution for this.

http://rightprospectus-stage.rightprospectus.com/documents/BlackRock/SUM_AllCapEnergyResourcesPortfolioServiceShares.pdf

@gsampath127
Copy link

Can someone please respond here . Is the issue is fixed if in which version.

var dest = outlineDict.get('A');
if (dest) {
if (dest.has('URI')) {
dest = dest.get('URI');
} else {
dest = dest.get('D');
}

The code is working when we the open pdf from local system.
When the pdf document is opened as query string to the viewer. The issue still exists.

http://rightprospectus-stage.rightprospectus.com/documents/BlackRock/SUM_AllCapEnergyResourcesPortfolioServiceShares.pdf

@timvandermeij
Copy link
Contributor

We have pull request #6822 to implement this, though the review for it needs to be completed. It is not fixed yet, otherwise this issue would have been closed.

@timvandermeij
Copy link
Contributor

Closing as fixed by #6822. URLs in document outlines are now supported. The other outline issues are tracked in #3214.

@creage
Copy link

creage commented Aug 25, 2017

I have an example PDF document with bookmarks. Adobe navigates by them fine, but viewer does not. Exploring the DOM of the document outline displays empty href attributes

image

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Aug 25, 2017

@creage Next time, please open a new issue rather than commenting on a old and already fixed one (see also CONTRIBUTING.md)!
Furthermore, note that your PDF file is actually not valid according to the specification, since its outline data isn't correct.

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

No branches or pull requests

8 participants