This bundle provides a simple integration of the "PDF.JS library" from mozilla into Symfony2.
Using the vendors script
Add the following lines to the deps
file at the root of your project file:
[SalvaPdfJsBundle]
git=http://github.com/nibsirahsieu/SalvaPdfJsBundle.git
target=bundles/Salva/PdfJsBundle
Next, update your vendors by running:
$ ./bin/vendors install
Using composer
Tell composer to download the bundle by running the command:
$ php composer.phar require salva/pdfjs-bundle:1.0.*@dev
Add the following entry to your autoloader:
<?php
// app/autoload.php
$loader->registerNamespaces(array(
// ...
'Salva' => __DIR__.'/../vendor/bundles',
));
Finally, enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Salva\PdfJsBundle\SalvaPdfJsBundle(),
);
}
<?php
$file = '/uploads/yourpdf.pdf'; //relative to your website root directory
return $this->get('salva_pdf_js.controller')->renderPdf($file);