Example #1
0
 /**
  * @expectedException \PhantomPdf\PhantomPdfException
  * @expectedExceptionMessage /wrong/binary
  */
 public function testExceptionBinaryDoesNotExist()
 {
     $wrongBinaryPath = '/wrong/binary';
     $this->setExpectedException('Exception', $wrongBinaryPath);
     $htmlMock = $this->getContentMock();
     $pdfGenerator = new PdfGenerator('/wrong/binary');
     $pdfGenerator->renderOutputFromHtml($htmlMock);
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     //phantom-pdf
     $this->app->bind('phantom-pdf', function () {
         $generator = new PdfGenerator();
         $generator->setBaseUrl($this->app['config']['phantom-pdf::base_url'] ?: url());
         $generator->setBinaryPath($this->app['config']['phantom-pdf::binary_path']);
         $generator->setStoragePath($this->app['config']['phantom-pdf::temporary_file_path']);
         $generator->setTimeout($this->app['config']['phantom-pdf::timeout']);
         if ($this->app['config']['phantom-pdf::ignore_ssl_errors']) {
             $generator->ignoreSSLErrors();
         }
         foreach ($this->app['config']['phantom-pdf::command_line_options'] as $option) {
             $generator->addCommandLineOption($option);
         }
         $this->app->finish(function () use($generator) {
             $generator->deleteTempFiles();
         });
         return $generator;
     });
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'phantom-pdf');
     $this->app->singleton('phantom-pdf', function () {
         $generator = new PdfGenerator();
         $generator->setBaseUrl($this->app['config']['phantom-pdf.base_url'] ?: url());
         $generator->setBinaryPath($this->app['config']['phantom-pdf.binary_path']);
         $generator->setStoragePath($this->app['config']['phantom-pdf.temporary_file_path']);
         $generator->setTimeout($this->app['config']['phantom-pdf.timeout']);
         foreach ($this->app['config']['phantom-pdf.command_line_options'] as $option) {
             $generator->addCommandLineOption($option);
         }
         return $generator;
     });
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'phantom-pdf');
     $this->app->singleton('phantom-pdf', function () {
         $generator = new PdfGenerator();
         $baseUrl = $this->app['config']['phantom-pdf.base_url'];
         $generator->setBaseUrl(is_null($baseUrl) ? null : url($baseUrl));
         $generator->setBinaryPath($this->app['config']['phantom-pdf.binary_path']);
         $generator->setStoragePath($this->app['config']['phantom-pdf.temporary_file_path']);
         $generator->setTimeout($this->app['config']['phantom-pdf.timeout']);
         if ($this->app['config']['phantom-pdf.conversion_script']) {
             $generator->useScript($this->app['config']['phantom-pdf.conversion_script']);
         }
         foreach ($this->app['config']['phantom-pdf.command_line_options'] as $option) {
             $generator->addCommandLineOption($option);
         }
         return $generator;
     });
     $this->app->alias('phantom-pdf', PdfGenerator::class);
 }
 /**
  * @covers ::validateStoragePath
  */
 public function testBadStoragePath()
 {
     $generator = new PdfGenerator();
     $generator->setStoragePath(__DIR__ . '/no-storage-path');
     $this->setExpectedException('Exception', 'The specified storage path is not writable');
     $generator->saveFromView('test', $this->files . 'no.pdf');
 }