Last week we updated Chrome to version 92.0.4515 and after that the preview of some pdf files is not working (it still works for some others).
We think it's a problem with the version of pdfjs, which it happens in Edge and Firefox too (not in Opera), and we have found similar issues for another technologies, related to old versions of pdfjs:
https://github.com/wojtekmaj/react-pdf/issues/819
I have tried to replace the pdfjs version of Share (Alfresco Share 6.2 in my case) with a newer one but it seems that it is not easy, at least for me. Has anyone else had this issue? From what I've seen, it also happens in Alfresco Share 7.0
This file can be used to test: https://github.com/wojtekmaj/react-pdf/files/6892265/broken_pdf_bill.pdf
Thanks in advance and best regards
Solved! Go to Solution.
I share my solution to this if you don't want to upgrade the whole component.
As suggested in https://github.com/mozilla/pdf.js/issues/13870 you can change the line 38748 of file pdf.worker.js from this:
var widths = [];
to
var widths = Object.create(null);
And everything will work fine.
You will have to recreate the min file or delete it.
Regards
I upgraded pdfjs to 2.6.347 for a customer on ACS 6.2 earlier this year due to broken PDF rendering on some browsers for some types of PDF files. Due to Aikau and some config / API changes in pdfjs, you also need to adapt the PdfJs.js file in Share's /components/preview/ static resource path. My customisation did not directly update the pdfjs version included with Aikau, which should probably done if you also want previews in the faceted search result screen to work properly (not really relevant for the customer's case).
Ok, thanks, Axel. Anyway, we have tried it with version 2.5.7 (the one that Alfresco 7 uses) and it also fails in the latest version of Chrome. And reading the post that I linked, it seems that it also fails in 2.6.347. I guess we will have to try to migrate to 2.9.359 manually.
I share my solution to this if you don't want to upgrade the whole component.
As suggested in https://github.com/mozilla/pdf.js/issues/13870 you can change the line 38748 of file pdf.worker.js from this:
var widths = [];
to
var widths = Object.create(null);
And everything will work fine.
You will have to recreate the min file or delete it.
Regards
Hi @eljuaner
Thank you for posting your solution - really helpful to other users!
Cheers,
Hey,
UPDATE: I posted this question as a separate question .
I have an Alfresco 5.0 CE (we use share-frontend) and upgraded to version pdf.js 1.10.100 (with the help of this merge ), because of rendering issues. 1.10.100 is the last 1.x version of pdfjs. Unfortunately my rendering issues are not resolved completely. So I tried to move to a 2.x version of pdfjs, but I'm struggling with it. I get an Uncaught ReferenceError: PDFJS is not define. I have to adapt the PdfJs.js file.
@afaustPlease can you help me? I read, that you did an upgrade of pdfjs, so I think you have a PdfJs-Module, which should work with pdfjs 2.x? It would be very nice, if you could respond. Do you have a recommendation for me
Thanks!
Best regards
Hello Axel,
May I ask you how did you update the version of pdfjs? My very first try was a bit of brute force, building both generic and minified versions of pdf.js freshly taken from the repo [1] and copying them under /usr/local/tomcat/webapps/share/components/preview/pdfjs/ Unfortunately with this I am getting an ugly error in the javascript console
Uncaught ReferenceError: PDFJS is not defined
You mentioned that "you also need to adapt the PdfJs.js file in Share's /components/preview/ static resource path" I am wondering if you could share this bit, I am sure that it can be very helpful to other users.
Thanks in advance,
Luis
ps: very nice hack Juan!
[1] https://github.com/mozilla/pdf.js
$ gulp generic $ gulp minified
Hello Axel,
Ups, I've realized that you posted your solution here thanks! I am having a look
Cheers,
Luis
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.