Blank Screen in some PDF Documents

Which product are you using?

PDF.js Express Version

Detailed description of issue
Hey guys,

In some moments when I load a pdf, the Viewer only shows a white screen.

This is very rare but it happens.

Just refresh and the document loads correctly.

It is not always the same document that gives the error. It’s random.

I would like to detect when this happens to reload the page.

Is there something in the API that identifies that the viewer has a white screen?

I tried the loaderror event, but the white screen doesn’t throw any errors.

Any idea?

Thanks in advance.

Marcio Branco.

Expected behaviour
{some way to identify that the page did not load.}

Does your issue happen with every document, or just one?

Link to document
{Not always the same document}

Code snippet

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:


Hey there,

I cannot reproduce your issue. There’s not much I can do here unless you can provide exact steps to reproduce, or a document that consistently reproduces the issue.


Hi Logan,

Thanks for your response.

The problem is exactly this. I don’t have a document that consistently fails with white screen.

It’s totally occasional.

The document that failed now works if I refresh the page.

I tried using “loaderror” to generate an event but it didn’t work. I intentionally loaded a failed pdf and the loaderror was generated normally. So this white screen event doesn’t generate an error that “loaderror” detects.

I noticed that after the document fails the first time and I run refresh. He will not fail again. As if the document is loaded into a cache.

I’m currently trying to use absurd code solutions like loading the document once and then performing a refresh. But it’s not working consistently.

An additional information is that the machines where the white screen appears are in another office of ours. Behind a firewall.

The machines on our side of the firewall never fail. So the network is to blame. But we are not able to find out what is causing this.

Another thing that makes it difficult is the refresh to work. If it was the firewall blocking something it would never work.

I’m almost giving up.

A question: Is there any property that informs that the viewer has a visible document?

I used “documentloaded”. But when the white screen occurs the event is not generated.

Well… Sorry for the long text.

Thanks for listening.

Marcio Branco.

Hey there,

Since the error is unpredictable and you’re not sure what is causing it, I can’t really recommend an event/error handler for you to listen to. The only thing I can think of is checking if documentloaded isn’t called, then do a refresh (doing a refresh on error obviously is not a good solution though).

There is not much I can do to help you here. If you can find some error message, weird network behaviour, or anything else you think might be useful, feel free to send it and I’ll see if I can help. But right now I just do not have enough information to give you any concrete advice.