pdfjs not working sometimes on Chrome 92

cancel
Showing results for 
Search instead for 
Did you mean: 
eljuaner
Active Member II

pdfjs not working sometimes on Chrome 92

Jump to solution

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

https://stackoverflow.com/questions/68581278/pdfs-not-rendering-perfectly-after-chrome-92-version-up...

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

 

 

1 Solution

Accepted Solutions
eljuaner
Active Member II

Re: pdfjs not working sometimes on Chrome 92

Jump 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

 

 

 

 

View solution in original post

7 Replies
afaust
Master

Re: pdfjs not working sometimes on Chrome 92

Jump to solution

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).

eljuaner
Active Member II

Re: pdfjs not working sometimes on Chrome 92

Jump to solution

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.

eljuaner
Active Member II

Re: pdfjs not working sometimes on Chrome 92

Jump 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

 

 

 

 

EddieMay
Alfresco Employee

Re: pdfjs not working sometimes on Chrome 92

Jump to solution

Hi @eljuaner 

Thank you for posting your solution - really helpful to other users!

Cheers,

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
wuarmin
Active Member II

Re: pdfjs not working sometimes on Chrome 92

Jump to solution

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 

uo67113
Active Member

Re: pdfjs not working sometimes on Chrome 92

Jump to solution

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 Smiley Sad

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! Smiley Happy

[1] https://github.com/mozilla/pdf.js

$ gulp generic
$ gulp minified 
uo67113
Active Member

Re: pdfjs not working sometimes on Chrome 92

Jump to solution

Hello Axel,

Ups, I've realized that you posted your solution here thanks! I am having a look

Cheers,

Luis