anglemx / pdf-viewer-bundle
PDF In-browser viewer based on PDF.js
Installs: 18
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:Twig
Type:symfony-bundle
Requires
- php: >=8.1
- symfony/dependency-injection: ^5.4
- symfony/framework-bundle: ^5.4
- symfony/twig-bundle: ^4.4|^5.0|^6.0
- twig/twig: ^2.13|^3.0.4
Requires (Dev)
- dms/phpunit-arraysubset-asserts: ^0.2.0
- php-coveralls/php-coveralls: ^2.2
- phpunit/phpunit: ^9.0
README
PDF in-browser viewer using the PDF.js library to render documents with HTML5.
Current build using PDF.js release v4.0.379.
Installation
Install composer dependency:
composer require anglemx/pdf-viewer-bundle
Make sure that the Bundle has been enabled and auto-wired in the bundles.php
file.
// config/bundles.php return [ // ... Angle\PDFViewerBundle\AnglePDFViewerBundle::class => ['all' => true], // ... ];
Configure routing
As per the official Symfony documentation:
Routing is never automatically imported in Symfony.
This means that your application will need to explicitly import the routes to enable the bundle's controller.
angle_pdf_viewer: resource: "@AnglePDFViewerBundle/Resources/config/routes.yaml"
Usage
return $this->redirectToRoute('angle_pdf_viewer_view', ['file' => '/path/to/file']);
<a href="{{ path('angle_pdf_viewer_view', {'file': '/path/to/file'}) }}">View PDF</a>
Quick Test
Try to access the following URL after installing:
/_pdf?file=/bundles/anglepdfviewer/vendor/pdfjs/web/compressed.tracemonkey-pldi-09.pdf