A powerful and elegant web-based document viewer that allows users to open, preview, and interact with documents directly in the browser using URL or file upload.
A sleek browser-based document viewer supporting PDF, Office, and OpenDocument formats with smart retry logic, multiple rendering providers (Google Docs, Microsoft Office), and file upload fallback via temporary hosting services.
Supports a wide range of document types:
- DOC / DOCX
- XLS / XLSX
- PPT / PPTX
- ODT / ODS / ODP
Automatically selects the best rendering provider:
- Google Docs Viewer
- Microsoft Office Online
- Native browser preview (fallback)
Includes:
- Automatic retry mechanism (3 attempts)
- Provider switching on failure
- Timeout handling
Upload files directly from your device:
- Uses catbox.moe (primary)
- Fallback to tmpfiles.org
- Temporary hosting (auto-expiry)
- Clean iOS-inspired UI
- Dark mode support (auto-detect)
- Animated loader with progress tracking
- Scroll progress indicator
- Drag & drop upload
- Toast notifications
- Multi-provider fallback
- Smart detection of failed loads
- Retry visualization with progress dots
- Graceful error handling
Paste a file link:
https://example.com/file.pdf
- Drag & drop file
- Or use upload button
| Attempt | Provider |
|---|---|
| 1 | Google Docs Viewer |
| 2 | Microsoft Office Viewer |
| 3 | Google Drive Viewer |
| Final | Native browser |
- HTML5
- CSS3 (Custom Properties, Animations)
- Vanilla JavaScript
project/
│── index.html # Main application file
│── README.md # Documentation
Handles:
- Provider switching
- Retry logic
- Timeout fallback
- Catbox API integration
- Tmpfiles fallback
- Blob preview fallback
- Loader state
- Error state
- Viewer state
- Toast notifications
git clone https://github.com/psvineet/document-viewer.git
cd document-viewer
open index.htmlOr deploy using:
- GitHub Pages
- Netlify
- Vercel
- Uploaded files are temporary (auto-deleted after ~72 hours)
- Cross-origin restrictions may limit preview detection
- Some file types rely on external viewers
- Add authentication-based storage
- Improve mobile gestures (zoom/pinch)
- Add annotation tools
- Offline preview support
Developed by Vineet
- Google Docs Viewer
- Microsoft Office Online
- Catbox.moe
- Tmpfiles.org
This project is open-source and available under the MIT License.