Hey everyone,
I’m trying to use Google Docs Viewer to show PDFs on my website. But I’m having trouble with big files. The viewer keeps timing out and shows an error message:
Sorry, it took too long to find the document at the original source. Please try again later.
You can also try to download the original document by clicking here.
Right now, I’m using this code to embed the viewer:
<iframe id="pdfFrame" src="example.pdf&embedded=true" width="1000" height="800"></iframe>
Does anyone know how to increase the timeout limit or remove it completely? I’ve looked for documentation but can’t find anything helpful. Any tips or tricks would be great. Thanks!
I’ve encountered this issue before, and while there’s no direct way to modify Google Docs Viewer’s timeout, I’ve found an alternative solution. Consider using PDF.js, an open-source PDF viewer developed by Mozilla. It’s highly customizable and doesn’t have the same timeout limitations as Google Docs Viewer.
To implement PDF.js, you’ll need to include the necessary JavaScript files and create a canvas element for rendering. The basic setup looks like this:
<script src=\"https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.9.359/pdf.min.js\"></script>
<canvas id=\"pdf-viewer\"></canvas>
Then use JavaScript to load and render the PDF. This approach gives you more control over the viewing experience and handles large files better. It may require a bit more setup, but it’s worth it for reliability with larger documents.
hey, have u tried using mozilla’s pdf.js? its pretty good for big files. i used it on my site and it works great. no timeouts like google docs viewer. plus u can customize it more. might be worth checkin out if ur still having probs
I’ve faced similar issues with Google Docs Viewer and large PDFs. From my experience, there’s no direct way to increase the timeout limit as it’s set on Google’s end. However, I’ve found a workaround that might help.
Instead of linking directly to your PDF, try using Google Drive as an intermediary. Upload your large PDF to Google Drive, set the sharing permissions to ‘Anyone with the link can view’, and then use the file ID in your iframe src.
The URL format would be:
https://drive.google.com/file/d/[FILE_ID]/preview
This method has worked well for me with files up to 50MB. It’s not perfect, but it’s more reliable than linking directly to your server. Also, consider splitting very large PDFs into smaller parts if possible. This can improve load times and reduce timeout issues.
Hope this helps! Let me know if you need any clarification on the process.