src/Filter/LibreOffice/Convert.php
public function process(ThingInterface $thing, $sourcePath, OptionsInterface $options = null)
    {
        $tmpDir = $this->tmpFs->createTemporaryDirectory();

        /** @var DocumentOptions $options */
        $options = $this->defaults->merge($options);

        $pb = $this->soffice
            ->getProcessBuilder()
            ->format($options->getFormat())
            ->input($sourcePath)
            ->outputDir($tmpDir);

        // we override the home directory so it does not cause collisions if soffice is run multiple times concurrently
        $pb->setEnv('HOME', $this->tmpFs->createTemporaryDirectory());

        $process = $pb->getProcess();

        $code = $process->run();

        // https://github.com/dagwieers/unoconv/issues/192
        if($code === 81) {
            $code = $process->run();
        }

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

        return glob(sprintf('%s/*', $tmpDir));
    }
public function process(ThingInterface $thing, $sourcePath, OptionsInterface $options = null)
    {
        $tmpDir = $this->tmpFs->createTemporaryDirectory();

        /** @var DocumentOptions $options */
        $options = $this->defaults->merge($options);

        $pb = $this->soffice
            ->getProcessBuilder()
            ->format($options->getFormat())
            ->input($sourcePath)
            ->outputDir($tmpDir);

        // we override the home directory so it does not cause collisions if soffice is run multiple times concurrently
        $pb->setEnv('HOME', $this->tmpFs->createTemporaryDirectory());

        $process = $pb->getProcess();

        $code = $process->run();

        // https://github.com/dagwieers/unoconv/issues/192
        if($code === 81) {
            $code = $process->run();
        }

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

        return glob(sprintf('%s/*', $tmpDir));
    }
@param ThingInterface                        $thing
@param string                                $sourcePath
@param OptionsInterface|null|DocumentOptions $options

@throws \Asoc\Dadatata\Exception\ProcessingFailedException
@return array Paths to generated files