PDF not displaying consistently in iframe using Google Drive viewer in Angular

I’m working on an Angular application where I need to embed PDF documents using an iframe. I’m using Google Drive’s viewer service to display these files, but I’m running into reliability issues.

The problem is that the PDF viewer works inconsistently - sometimes the document loads and displays perfectly, but other times it just shows a blank iframe or fails to load entirely. This inconsistent behavior is causing problems for users who need to view these documents reliably.

Has anyone experienced similar issues with Google Drive’s PDF viewer in Angular applications? What would be the best approach to ensure the PDF documents load consistently every time? Are there any alternative solutions or workarounds that might provide more stable PDF viewing functionality?

Any suggestions for making this more reliable would be greatly appreciated.

totally agree, it can be really hit or miss! trying out pdf.js sounds like a solid plan. and yeah, make sure those PDFs are set to public, that can def save you from a lot of headaches.

Same headache here for over a year. It’s usually CORS issues and Google’s rate limiting on their viewer. Here’s what fixed it for me: I ping the Google Drive viewer URL first before embedding the iframe. If it fails or times out, I skip straight to downloading the PDF and use a local viewer instead. Also, Google’s viewer is trash on mobile - you’ll need separate handling there. Honestly, the inconsistency got so annoying we ditched it entirely. Now we serve PDFs from our own CDN with PDF.js. Way more reliable and no random failures.

Google Drive viewer is notorious for these random loading issues, especially with high-traffic apps. Had this exact problem six months ago and fixed it with a fallback that checks if the iframe loads within a reasonable time. If it doesn’t, my app automatically switches to a different PDF renderer. What I found was Google Drive viewer sometimes throttles requests or has random service hiccups that aren’t obvious. Set up a timeout function that catches failed loads and either retries Google Drive or switches to something like PDF.js. This cut our document viewing support tickets way down and made things way more reliable for users.