|
| 1 | +# ng-pdf-renderer |
| 2 | + |
| 3 | +A modern, zero-configuration Angular PDF viewer component with built-in controls for navigation, zoom, rotation, search, print, and download. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- ✅ **Zero Configuration** - Automatically configures PDF.js worker |
| 8 | +- ✅ **Continuous Scrolling** - View all pages in a single scrollable view |
| 9 | +- ✅ **Text Selection** - Select and copy text from PDFs |
| 10 | +- ✅ **Search** - Find text within PDFs with highlighting |
| 11 | +- ✅ **Navigation** - Page controls with automatic current page tracking |
| 12 | +- ✅ **Zoom & Rotation** - Built-in zoom and rotation controls |
| 13 | +- ✅ **Print & Download** - Easy print and download functionality |
| 14 | +- ✅ **Responsive** - Auto-fits to container width |
| 15 | +- ✅ **High-DPI Support** - Sharp rendering on retina displays |
| 16 | +- ✅ **Modern Angular** - Standalone components with signals |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +```bash |
| 21 | +npm install ng-pdf-renderer |
| 22 | +``` |
| 23 | + |
| 24 | +## Quick Start |
| 25 | + |
| 26 | +```typescript |
| 27 | +import { Component } from '@angular/core'; |
| 28 | +import { PdfViewerComponent } from 'ng-pdf-renderer'; |
| 29 | + |
| 30 | +@Component({ |
| 31 | + selector: 'app-root', |
| 32 | + standalone: true, |
| 33 | + imports: [PdfViewerComponent], |
| 34 | + template: ` |
| 35 | + <ng-pdf-viewer |
| 36 | + [src]="pdfUrl" |
| 37 | + [options]="pdfOptions"> |
| 38 | + </ng-pdf-viewer> |
| 39 | + ` |
| 40 | +}) |
| 41 | +export class AppComponent { |
| 42 | + pdfUrl = '/assets/sample.pdf'; |
| 43 | + |
| 44 | + pdfOptions = { |
| 45 | + height: '800px', |
| 46 | + showControls: true, |
| 47 | + enableTextSelection: true, |
| 48 | + autoFit: true |
| 49 | + }; |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +## Options |
| 54 | + |
| 55 | +| Option | Type | Default | Description | |
| 56 | +|--------|------|---------|-------------| |
| 57 | +| `src` | string \| Uint8Array | required | PDF source (URL or byte array) | |
| 58 | +| `options.height` | string | '600px' | Container height | |
| 59 | +| `options.showControls` | boolean | true | Show navigation controls | |
| 60 | +| `options.enableTextSelection` | boolean | true | Enable text selection | |
| 61 | +| `options.autoFit` | boolean | true | Auto-fit PDF to container width | |
| 62 | +| `options.initialZoom` | number | 1 | Initial zoom level | |
| 63 | + |
| 64 | +## Browser Support |
| 65 | + |
| 66 | +- Chrome (latest) |
| 67 | +- Firefox (latest) |
| 68 | +- Safari (latest) |
| 69 | +- Edge (latest) |
| 70 | + |
| 71 | +## License |
| 72 | + |
| 73 | +MIT |
| 74 | + |
| 75 | +## Contributing |
| 76 | + |
| 77 | +Contributions are welcome! Please feel free to submit a Pull Request. |
0 commit comments