2017 © Pedro Peláez
 

symfony-bundle pdfjs-viewer-bundle

This bundle provides an integration of pdf.js from mozilla with Symfony 4 framework and customizable parameters on server side.

image

jjalvarezl/pdfjs-viewer-bundle

This bundle provides an integration of pdf.js from mozilla with Symfony 4 framework and customizable parameters on server side.

  • Friday, May 18, 2018
  • by jjalvarezl
  • Repository
  • 0 Watchers
  • 0 Stars
  • 392 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 5 Versions
  • 84 % Grown

The README.md

JjalvarezlPDFjsViewerBundle

Build Status Total Downloads Latest Stable Version Latest Unstable Version License, (*1)

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)

  • This bundle renders a pdf with on server side. For this reazon you can have an alternative solution to the default browser viewer that can variate the way that a pdf can be loaded on each browser type.
  • This bundle can access files in every part of the server.
  • This bundle can delete the pdf after rendering it.

Installation

1) Download JjalvarezlPDFjsViewerBundle

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], ];

3) Install assets

Don't forget to install assets, is the only way that this bundle works:, (*8)

$ php app/console assets:install --symlink --relative

Concepts before usage:

First at all, its necessary to establish some taxonomy an initial concepts in order to understand how it works:, (*9)

  • Webroot: is the web folder of Symfony
  • "PDF.js" works only in webroot folders in all kind of projects.
  • This bundle enables to "PDF.js" to show pdf files in any place that you need to obtain them.
  • It makes a temporal copy with the absolute path of the pdf file in a custom temporal dir inside webroot (defined by the developer). So make sure about the right permissions (files + owner).
  • Once "PDF.js" loads the pdf file, this bundle can immediately delete it from webroot in order to avoid issues such as disk space overflow.
  • This bundle also can show or hide visual "PDF.js" components.

All those features can be performed with parameters which have only true / false values as follows:, (*10)

Usage

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)

Support

  • Email: jhon.jairo.alvarez.londono@gmail.com

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)

The Versions

18/05 2018

dev-master

9999999-dev

This bundle provides an integration of pdf.js from mozilla with Symfony 4 framework and customizable parameters on server side.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

by Avatar jjalvarezl

symfony2 symfony pdfjs pdf viewer symfony4

01/03 2018

v3.0.0

3.0.0.0

This bundle provides an integration of pdf.js from mozilla with Symfony 3 framework and customizable parameters on server side

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

by Avatar jjalvarezl

symfony3 symfony pdfjs pdf viewer

01/03 2018

dev-sf3

dev-sf3

This bundle provides an integration of pdf.js from mozilla with Symfony 3 framework and customizable parameters on server side

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

by Avatar jjalvarezl

symfony3 symfony pdfjs pdf viewer

01/03 2018

v2.0.0

2.0.0.0

This bundle provides an integration of pdf.js from mozilla with Symfony 2 framework and customizable parameters on server side

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

by Avatar jjalvarezl

symfony2 symfony pdfjs pdf viewer

01/03 2018

dev-sf2

dev-sf2

This bundle provides an integration of pdf.js from mozilla with Symfony 2 framework and customizable parameters on server side

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

by Avatar jjalvarezl

symfony2 symfony pdfjs pdf viewer