Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • 5.x
  • 6.x
  • 6.1.1
  • 6.1.0
  • 5.0.2
  • 6.0.1
  • 6.0.0
  • 5.0.0
  • 5.0.1
  • 4.0.0
11 results

PdfMergeShellCommandQpdf.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    PdfMergeShellCommandQpdf.php 974 B
    <?php
    
    namespace UnicaenPdf\Command;
    
    use UnicaenPdf\Command\PdfMergeShellCommandInterface;
    use UnicaenShell\Command\ShellCommand;
    
    /**
     * Commande de concaténation de N fichiers PDF.
     *
     * Version utilisant 'qpdf'.
     */
    final class PdfMergeShellCommandQpdf extends ShellCommand implements PdfMergeShellCommandInterface
    {
        public function getName(): string
        {
            return 'MergeShellCommandQpdf';
        }
    
        public function checkRequirements(): void
        {
            $this->assertExecutableExists();
        }
    
        public function generateCommandLine()
        {
            // Commande de fusion (cf. https://qpdf.readthedocs.io/en/10.5/cli.html#page-selection-options)
            $command = $this->executable .
                sprintf(' --warning-exit-0 %s --pages . %s -- %s',
                    array_shift($this->inputFilesPaths),
                    implode(' ', $this->inputFilesPaths),
                    $this->outputFilePath
                );
    
            $this->commandLine = $command;
        }
    }