share-extras / media-viewers

Enhanced document previews for a range of different document and media types, plus a dashlet allowing any content item to be displayed on a site dashboard.
Apache License 2.0
29 stars 23 forks source link

PDF.js media viewers does not respect links #8

Open igorbga opened 11 years ago

igorbga commented 11 years ago

When the PDF.js media viewer shows a document, if the document has links those do not work. In flash preview you could click on the embedded links without any problems.

I have checked a sample document with mozilla's PDF.js demo and they work so I think it must be an issues with the Share Extras integration.

loftux commented 11 years ago

Could you please try and check out and build the pdfjs branch? It has a fairly recent version of pdf.js library, so if it works on their demo page it will hopefully work in Media Viewers too.

igorbga commented 11 years ago

I've changed to branch pdf.js, downloaded it, opened in eclipse and build ANT target "dist-jar". I have replaced the media viewers jar with the resulting one.

But it seems there is some bug in the Javascript code as the previewer says that it can not download PDF content and the Javascript Console shows some errors in the minimized JS:

Uncaught TypeError: Property 'progressCallback' of object # is not a function pdf-min.js:1 Unhandled rejection: TypeError: Cannot read property 'name' of undefined

loftux commented 11 years ago

Did you build using ant -f project.xml dist-jar ? If not, that is probably why (we cannot compress pdf.js with yuicompress due to a bug). If you did, please specify what browser and version you are seeing this error.

igorbga commented 11 years ago

a ok, didn't know that. I've tried again after building as you mentioned.

Building this way the ant output shows still a task called yuicompress running but now the viewer loads and the document is shown. Nevertheless "TypeError: this.progressCallback is not a function" in line 226 of pdf-min.js is still shown in the javascript console. And the links don't work either, so it seems like pdfjs branch does not solve the problem.

I've tested it with several browsers and all of them behave in the same way:

  • Mozilla Firefox 21 in Ubuntu 12.04 64bit
  • Chromium Versión 25.0.1364.160 Ubuntu 12.04 (25.0.1364.160-0ubuntu0.12.04.1)
  • Mozilla Firefox 21 in Windows XP
  • Chrome 27.0.1453.110 in Windows XP

I'm running in Alfresco Community 4.0.d.

igorbga commented 11 years ago

The javascript error, might be related to this ? https://github.com/mozilla/pdf.js/pull/3368

loftux commented 11 years ago

Thanks for spotting that pdf.js issue. I was able to replicate it, and will add this fix as soon as it is merged in the pdf.js project. You can if you want to enable progressive loading, I've not enable it by default. Change row 753 in PdfJs.js to: PDFJS.disableRange = false; That should probable remove the error. Its a new feature, if you enabled it and find issue, please report in issue #1.

As for hyperlinking support, this must be implemented separately, a quick check in pdf.js project and their viewer implementation viewer.js tells that it does need to be implemented in the viewer (it is not part of core library). I'll keep this issue open as an enhancement request.

igorbga commented 11 years ago

Great, thanks.