Ejemplo n.º 1
1
 public static function pdfUploadEnabled()
 {
     if (!class_exists('\\XPDF\\PdfToText')) {
         return 'Missing dependency php-xpdf/php-xpdf; install it using composer';
     } else {
         try {
             $obj = \XPDF\PdfToText::create();
         } catch (\XPDF\Exception\BinaryNotFoundException $e) {
             return 'Cannot locate required binary "pdftotext". Package name
                 may be "poppler-utils" or "xpdf-utils" on Debian based distros or "xpdf"
                 on Red Hat based distros.';
         } catch (Exception $e) {
             return 'Unexpected error initializing pdftotext wrapper. Details: ' . $e->getMessage();
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 public function testCreate()
 {
     $finder = new ExecutableFinder();
     $php = $finder->find('php');
     if (null === $php) {
         $this->markTestSkipped('Unable to find PHP binary, required for this test');
     }
     $logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $pdfToText = PdfToText::create(array('pdftotext.binaries' => $php, 'timeout' => 42), $logger);
     $this->assertInstanceOf('XPDF\\PdfToText', $pdfToText);
     $this->assertEquals(42, $pdfToText->getProcessBuilderFactory()->getTimeout());
     $this->assertEquals($logger, $pdfToText->getProcessRunner()->getLogger());
     $this->assertEquals($php, $pdfToText->getProcessBuilderFactory()->getBinary());
 }
Ejemplo n.º 3
0
 public function register(Application $app)
 {
     $app['xpdf.configuration'] = array();
     $app['xpdf.default.configuration'] = array('pdftotext.timeout' => 60, 'pdftotext.binaries' => 'pdftotext');
     $app['xpdf.logger'] = null;
     $app['xpdf.configuration.build'] = $app->share(function (Application $app) {
         return array_replace($app['xpdf.default.configuration'], $app['xpdf.configuration']);
     });
     $app['xpdf.pdftotext'] = $app->share(function (Application $app) {
         $configuration = $app['xpdf.configuration.build'];
         if (isset($configuration['pdftotext.timeout'])) {
             $configuration['timeout'] = $configuration['pdftotext.timeout'];
         }
         return PdfToText::create($configuration, $app['xpdf.logger']);
     });
 }
Ejemplo n.º 4
0
 /**
  * @covers XPDF\PdfToText::load
  * @covers XPDF\PdfToText::getBinaryName
  */
 public function testLoad()
 {
     $this->assertInstanceOf('\\XPDF\\PdfToText', \XPDF\PdfToText::load($this->logger));
 }