08-03-2021 11:50 AM
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
08-09-2021 04:14 AM
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
08-04-2021 02:43 AM
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).
08-05-2021 10:29 AM
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.
04-25-2022 02:17 PM
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
04-26-2022 03:45 AM
Hello Axel,
Ups, I've realized that you posted your solution here thanks! I am having a look
Cheers,
Luis
08-09-2021 04:14 AM
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
08-10-2021 05:07 AM
Hi @eljuaner
Thank you for posting your solution - really helpful to other users!
Cheers,
10-11-2021 01:50 PM
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
Explore our Alfresco products with the links below. Use labels to filter content by product module.