This bundle provides an integration of pdf.js from mozilla with Symfony 4 framework and customizable parameters on server side.
This bundle provides a simple integration of the "PDF.JS library" from mozilla into Symfony 4 with different custom parameters., (*2)
Following features are supported: * Access to pdf outside from web directory. * Customizable pdf viewer options. * PDF.js incorporated until 23/03/2017., (*3)
Available at: * Packagist * GitHub, (*4)
Why use this?:, (*5)
Its necessary to provide the bundle's name in order to download it:, (*6)
``` bash $ php composer.phar require jjalvarezl/pdfjs-viewer-bundle, (*7)
### 2) Enable the bundle Enable the bundle in the kernel: ``` php <?php // config/bundles.php return [ // ... jjalvarezl\PDFjsViewerBundle\jjalvarezlPDFjsViewerBundle:class => ['all' => true], ];
Don't forget to install assets, is the only way that this bundle works:, (*8)
$ php app/console assets:install --symlink --relative
First at all, its necessary to establish some taxonomy an initial concepts in order to understand how it works:, (*9)
All those features can be performed with parameters which have only true / false values as follows:, (*10)
You can choose from different ways to use this bundle:, (*11)
Fast testing, (*12)
You can verify functionality in multiple browsers, you can enable the default "PDF.js viewer" with same loaded pdf in your function controller that returns a response:, (*13)
return $this->get('jjalvarezl_pdfjs_viewer.viewer_controller')->renderTestViewer();
Default viewer, (*14)
This shows same pdf viewer as the fast testing but its necessary to configure some extra parameters:, (*15)
$parameters = array( //Tell to the bundle that the pdf is outside the webroot 'isPdfOutsideWebroot' => true, //Tell to the bundle where is the pdf. (absolute path for outside temporal folder pdf, just the <name>.pdf for inside temporal folder) 'pdf' => '/home/jjalvarezl/Descargas/123.pdf', //Tell to the bundle that its necessary to delete pdf after render. 'deletePdfInTmpAfterRenderized' => false, ); return $this->get('jjalvarezl_pdfjs_viewer.viewer_controller')->renderDefaultViewer($parameters);
Custom viewer, (*16)
Also, you can customize which elements from viewer you want to display by editing the parameters:, (*17)
$parameters = array( //Same parameters as defalt viewer. //pdf.js viewer options 'showToolBar' => true, 'showLeftToolbarButton' => true, 'showSearchInDocumentButton' => true, 'showPreviousPageButton' => true, 'showPreviousPageButton' => true, 'showFindPageInputText' => true, 'showNumberOfPagesLabel' => true, 'showZoomInButton'=> false, 'showZoomOutButton'=> false, 'showScaleSelectComboBox'=> false, 'showPresentationModeButton'=> true, 'showOpenFileButton'=> true, 'showPrintButton'=> true, 'showDownloadButton'=> true, 'showViewBookmarkButton'=> true, 'showToolsButton'=> true, ); return $this->get('jjalvarezl_pdfjs_viewer.viewer_controller')->renderCustomViewer($parameters);
Here you can play with this parameters as you wish for customize the pdf viewer., (*18)
Please email me if you see something wrong or abnormal., (*19)
You can always be a contributor or you can add an issue here, (*20)