porting fix #4548 from pdf.js

https://github.com/mozilla/pdf.js/issues/4548