mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.4k stars 9.97k forks source link

[Bug]: pdfjs-dist not working in chrome #18957

Open lhilgert9 opened 3 hours ago

lhilgert9 commented 3 hours ago

Attach (recommended) or Link to PDF file

Every PDF

Web browser and its version

Google Chrome: 130.0.6723.59

Operating system and its version

macOS 15.0.1

PDF.js version

pdfjs-dist: 4.7.76

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No

Steps to reproduce the problem

  1. use pdfjs-dist in a web-app as follows:
    
    import * as pdfJS from 'pdfjs-dist';
    pdfJS.GlobalWorkerOptions.workerSrc = window.location.origin + '/pdf.worker.min.js';

export default pdfJS;

2. build your own pdf viewer
3. open the web-app in chrome

### What is the expected behavior?

The file should be displayed correctly, like in safari.

### What went wrong?

```js
Uncaught TypeError: Failed to construct 'Headers': Invalid name
    at PDFNetworkStreamFullRequestReader._onHeadersReceived (pdfjs-dist.js?v=b25d4dee:10221:29)
    at NetworkManager.onStateChange (pdfjs-dist.js?v=b25d4dee:10109:22)

Link to a viewer

No response

Additional context

The error has only occurred since version 4.7.76. In version 4.6.82 everything works without errors. Looks like the error occurred here.

nicolo-ribaudo commented 3 hours ago

https://mozilla.github.io/pdf.js/web/viewer.html works in Chrome without any problem. Please provide a link to a reproduction.

Snuffleupagus commented 3 hours ago

Please see https://github.com/mozilla/pdf.js/blob/master/.github/CONTRIBUTING.md (emphasis mine):

If you are developing a custom solution, first check the examples at https://github.com/mozilla/pdf.js#learning and search existing issues. If this does not help, please prepare a short well-documented example that demonstrates the problem and make it accessible online on your website, JS Bin, GitHub, etc. before opening a new issue or contacting us in the Matrix room -- keep in mind that just code snippets won't help us troubleshoot the problem.