Commit a7c8a849 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Ajout des commandes shell de concaténation de fichiers PDF avec Ghostscript ou QPDF.

parent f6001127
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
CHANGELOG
=========

6.1.0
-----
- Ajout des commandes shell de concaténation de fichiers PDF avec Ghostscript ou QPDF.

6.0.1
-----
- Ajout d'une fonction statique afin de simplifier le code de création de PDF dans les applications. 
+2 −1
Original line number Diff line number Diff line
@@ -5,7 +5,8 @@
    "php": "^8.0",
    "mpdf/mpdf": "^8.0",
    "laminas/laminas-view": "^2.22",
    "laminas/laminas-dependency-plugin": "^2.1"
    "laminas/laminas-dependency-plugin": "^2.1",
    "unicaen/shell": "^1.0"
  },
  "require-dev": {
    "laminas/laminas-test": "^4.0",
+31 −10
Original line number Diff line number Diff line
@@ -2,7 +2,27 @@

namespace UnicaenPdf;

use UnicaenPdf\Command\PdfMergeShellCommandGs;
use UnicaenPdf\Command\PdfMergeShellCommandQpdf;
use UnicaenPdf\Options\ModuleOptions;
use UnicaenPdf\Options\ModuleOptionsFactory;

return [
    'unicaen-pdf' => [

    ],

    'unicaen-shell' => [
        'commands' => [
            PdfMergeShellCommandGs::class => [
                'executable' => '/usr/bin/gs',
            ],
            PdfMergeShellCommandQpdf::class => [
                'executable' => '/usr/bin/qpdf',
            ],
        ],
    ],

    'router' => [
        'routes' => [
        ],
@@ -15,6 +35,7 @@ return [
    ],
    'service_manager' => [
        'factories' => [
            ModuleOptions::class => ModuleOptionsFactory::class,
        ],
    ],
    'view_helpers' => [
+13 −0
Original line number Diff line number Diff line
<?php

namespace UnicaenPdf\Command;

trait PdfMergeShellCommandAwareTrait
{
    protected PdfMergeShellCommandInterface $pdfMergeShellCommand;

    public function setPdfMergeShellCommand(PdfMergeShellCommandInterface $pdfMergeShellCommand): void
    {
        $this->pdfMergeShellCommand = $pdfMergeShellCommand;
    }
}
 No newline at end of file
+42 −0
Original line number Diff line number Diff line
<?php

namespace UnicaenPdf\Command;

use UnicaenPdf\Command\PdfMergeShellCommandInterface;
use UnicaenShell\Command\ShellCommand;

/**
 * Commande de concaténation de N fichiers PDF.
 *
 * Version utilisant 'ghostscript'.
 */
final class PdfMergeShellCommandGs extends ShellCommand implements PdfMergeShellCommandInterface
{
    protected string $noCompressionOption = '-dColorConversionStrategy=/LeaveColorUnchanged -dDownsampleMonoImages=false -dDownsampleGrayImages=false -dDownsampleColorImages=false -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode';

    /**
     * @return string
     */
    public function getName(): string
    {
        return 'PdfMergeShellCommandGs';
    }

    public function checkRequirements(): void
    {
        $this->assertExecutableExists();
    }

    /**
     * @inheritDoc
     */
    public function generateCommandLine()
    {
        $command = $this->executable . ' ' . $this->noCompressionOption;
        $command .=
            ' -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=' . $this->outputFilePath .
            ' -dBATCH ' . implode(' ', $this->inputFilesPaths);

        $this->commandLine = $command;
    }
}
 No newline at end of file
Loading