src/Filter/PDFBox/ExtractText.php
public function process(ThingInterface $thing, $sourcePath, OptionsInterface $options = null)
    {
        $tmpDir  = $this->tmpFs->createTemporaryDirectory();
        $tmpFile = $tmpDir.DIRECTORY_SEPARATOR.$thing->getKey();

        $pb      = $this->pdfBox->getProcessBuilder()
            ->extractText()
            ->source($sourcePath)
            ->output($tmpFile);
        $process = $pb->getProcess();

        $code = $process->run();
        if ($code !== 0) {
            throw ProcessingFailedException::create(
                'Failed to convert PDF to text',
                $code,
                $process->getOutput(),
                $process->getErrorOutput()
            );
        }

        return [$tmpFile];
    }
public function process(ThingInterface $thing, $sourcePath, OptionsInterface $options = null)
    {
        $tmpDir  = $this->tmpFs->createTemporaryDirectory();
        $tmpFile = $tmpDir.DIRECTORY_SEPARATOR.$thing->getKey();

        $pb      = $this->pdfBox->getProcessBuilder()
            ->extractText()
            ->source($sourcePath)
            ->output($tmpFile);
        $process = $pb->getProcess();

        $code = $process->run();
        if ($code !== 0) {
            throw ProcessingFailedException::create(
                'Failed to convert PDF to text',
                $code,
                $process->getOutput(),
                $process->getErrorOutput()
            );
        }

        return [$tmpFile];
    }
public function process ( ThingInterface $ thing , $ sourcePath , OptionsInterface $ options = null ) { $ tmpDir = $ this -> tmpFs -> createTemporaryDirectory ( ) ; $ tmpFile = $ tmpDir . DIRECTORY_SEPARATOR . $ thing -> getKey ( ) ; $ pb = $ this -> pdfBox -> getProcessBuilder ( ) -> extractText ( ) -> source ( $ sourcePath ) -> output ( $ tmpFile ) ; $ process = $ pb -> getProcess ( ) ; $ code = $ process -> run ( ) ; if ( $ code !== 0 ) { throw ProcessingFailedException :: create ( 'Failed to convert PDF to text' , $ code , $ process -> getOutput ( ) , $ process -> getErrorOutput ( ) ) ; } return [ $ tmpFile ] ; }
@param ThingInterface   $thing
@param string           $sourcePath
@param OptionsInterface $options

@throws \Asoc\Dadatata\Exception\ProcessingFailedException
@return array Paths to generated files
@param ThingInterface $thing @param string $sourcePath @param OptionsInterface $options