[Bug]: Cant render PDF:s on any phone devices. Neither with custom code or with pdf.js example app #19901
Unanswered
DanielssonWilliam
asked this question in
Q&A
Replies: 3 comments 8 replies
-
You probably need to use the |
Beta Was this translation helpful? Give feedback.
2 replies
-
@DanielssonWilliam Can you try https://mozilla.github.io/pdf.js/web/viewer.html? It's working for me both on Chrome and Firefox for Android. |
Beta Was this translation helpful? Give feedback.
6 replies
This comment has been hidden.
This comment has been hidden.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Attach (recommended) or Link to PDF file
On desktop: Renders correctly

On phone: Does not render

I have had problem rendering PDF:s on phone devices on my project using PDF:js. I first thought it was my fault. But after doing very heavy testing I have come to the conclusion that it most likely is a bug in pdf.js. Which I found wierd that no one has reported yet.
The bug is present on both iOS and Android and on all standard mobile web-browsers. Chrome, Safari, Firefox, Edge
I can get the pdf renderer to work no problem on desktop by cloning down the pdf.js repository and running the mobile-viewer example app.
But when running the same example on a phone. Emulator or real device then it is just blank. Nothing renderers.
The example uses a local PDF file. So it cant be CORS related. And I run in to the same problem when using my own PDF renderer in my own project that uses pdfjs-dist v. 5.2.133 which is the latest as of today.
I have also tried with lower versions and they have faced the same problem.
By doing some debugging I have found that it is the getDocument() function that is not resolving that is causing this problem. It fails silently which makes the pdf never load since it cant retrieve the document. This happens with local documents as well as documents that is fetched over the internet. Even mozillas own demo documents that are hosted does not load.
Web browser and its version
Google Chrome: Version 136.0.7103.48
Operating system and its version
macOS Version: 15.3.2 (24D81)
PDF.js version
pdfjs-dist: 5.2.133 and also latest version from cloning the repository and running the mobile-viewer example
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
How to replicate
git clone https://github.com/mozilla/pdf.js.git cd pdf.js
with
To be able to run it on a phone by hosting the app over the local network instead of localhost.
gulp dist-install
and rungulp server
:8888/examples/mobile-viewer/viewer.html
What is the expected behavior?
The PDF should render the same way as it does on a desktop in mobile-view. See image:
What went wrong?
Page is blank on any phone device, emulator or physical. And on both Android and iOS on any mobile browser. Firefox, Chrome, Safari or Edge
Example is on a Android emulator. But same behaviour is observed on a physical Iphone 12 device.
Link to a viewer
No response
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions