diff --git a/composer.json b/composer.json index 44ffaa29..b51ef494 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,8 @@ "zendframework/zendframework1": "^1.12", "geshi/geshi": "dev-master", "league/csv": "^8.1", - "doctrine/dbal": "^2.5" + "doctrine/dbal": "^2.5", + "mikehaertl/phpwkhtmltopdf": "^2.2" }, "include-path": ["library/"], "autoload": { diff --git a/composer.lock b/composer.lock index 75a87c88..d6968167 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "76f8460f611cfba3cf3d97294eebaca4", - "content-hash": "7e907f37c6d958ea6378c60240bed209", + "hash": "e99c2a7874dfdf3765c2593f120bbfb2", + "content-hash": "0d51a8356b2f1dd421c52d81f2d1331b", "packages": [ { "name": "doctrine/annotations", @@ -570,6 +570,127 @@ ], "time": "2016-09-05 08:16:07" }, + { + "name": "mikehaertl/php-shellcommand", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/mikehaertl/php-shellcommand.git", + "reference": "0de4e2cce17936ec7cef60a62c722a4aaa56c18c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mikehaertl/php-shellcommand/zipball/0de4e2cce17936ec7cef60a62c722a4aaa56c18c", + "reference": "0de4e2cce17936ec7cef60a62c722a4aaa56c18c", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "mikehaertl\\shellcommand\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Härtl", + "email": "haertl.mike@gmail.com" + } + ], + "description": "An object oriented interface to shell commands", + "keywords": [ + "shell" + ], + "time": "2016-07-16 09:42:31" + }, + { + "name": "mikehaertl/php-tmpfile", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/mikehaertl/php-tmpfile.git", + "reference": "b1b013cc29a8ee0423994b286d22e3aed6640d4e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mikehaertl/php-tmpfile/zipball/b1b013cc29a8ee0423994b286d22e3aed6640d4e", + "reference": "b1b013cc29a8ee0423994b286d22e3aed6640d4e", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "mikehaertl\\tmp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Härtl", + "email": "haertl.mike@gmail.com" + } + ], + "description": "A convenience class for temporary files", + "keywords": [ + "files" + ], + "time": "2016-07-07 05:59:42" + }, + { + "name": "mikehaertl/phpwkhtmltopdf", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/mikehaertl/phpwkhtmltopdf.git", + "reference": "318aed9ad8d7622c6d00a0fdf3b199e71d48e47e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mikehaertl/phpwkhtmltopdf/zipball/318aed9ad8d7622c6d00a0fdf3b199e71d48e47e", + "reference": "318aed9ad8d7622c6d00a0fdf3b199e71d48e47e", + "shasum": "" + }, + "require": { + "mikehaertl/php-shellcommand": "^1.0.2", + "mikehaertl/php-tmpfile": "^1.0.0", + "php": ">=5.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "mikehaertl\\wkhtmlto\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Haertl", + "email": "haertl.mike@gmail.com" + } + ], + "description": "A slim PHP wrapper around wkhtmltopdf with an easy to use and clean OOP interface", + "homepage": "http://mikehaertl.github.com/phpwkhtmltopdf/", + "keywords": [ + "pdf", + "wkhtmltoimage", + "wkhtmltopdf" + ], + "time": "2016-06-02 08:06:45" + }, { "name": "zendframework/zendframework1", "version": "1.12.20", diff --git a/library/Scores/Wkhtml/Pdf.php b/library/Scores/Wkhtml/Pdf.php deleted file mode 100644 index 377b1e8d..00000000 --- a/library/Scores/Wkhtml/Pdf.php +++ /dev/null @@ -1,53 +0,0 @@ -wkhtml = $c->profil->wkhtmltopdf->path; - } - - /** - * Défini les options supplémentaires à l'execution de wkhtmltopdf - * -n, --disable-javascript Do not allow webpages to run javascript. - * --disable-internal-links Do no make local links - * --disable-external-links Do no make links to remote web pages - * --user-style-sheet Specify a user style sheet, to load with every page. - * --print-media-type Use print media-type instead of screen. - * --header-left|right - * @param string $name - * @param string $value - */ - public function setOptions($name, $value = '') - { - $this->options[$name] = $value; - } - - /** - * Imprime un fichier HTML en PDF avec l'utilitaire wkhtmltopdf - * @param string $fileIn - * @param string $fileOut - * @return string Nom du fichier - */ - public function exec($fileIn, $fileOut = '') - { - if (empty($fileOut)) {$fileOut = str_replace('.html', '.pdf', $fileIn); } - if(file_exists($fileOut)){ unlink($fileOut); } - - $options = '--disable-internal-links'; - if ( count($this->options) ) - { - foreach ( $this->options as $name => $value ) - { - $options.= ' --'.$name; - if ($value!= '') $options.= ' "'.$value.'"'; - } - } - - $cmd = $this->wkhtml.' '.$options.' "'.$fileIn.'" "'.$fileOut.'"'; - exec( $cmd ); - return $fileOut; - } -} \ No newline at end of file diff --git a/library/WsScore/Pieces/v0.1/Service.php b/library/WsScore/Pieces/v0.1/Service.php index 6d916ab6..357ae81f 100644 --- a/library/WsScore/Pieces/v0.1/Service.php +++ b/library/WsScore/Pieces/v0.1/Service.php @@ -1,4 +1,6 @@ wsLog('kbis', $siren, basename($file)); } - //Génération du PDF - $pdf = new Scores_Wkhtml_Pdf(); - $fileOut = $pdf->exec($file, $filepdf); + // Génération du PDF + $pdf = new Pdf(); + $options = array( + 'binary' => $c->profil->wkhtmltopdf->path, + 'ignoreWarnings' => true, + 'disable-internal-links', + ); + $pdf->setOptions($options); + $pdf->addPage($file, array(), 'html'); + $pdf->saveAs($filepdf); if ( !file_exists($filepdf) ) { - throw new SoapFault('0000',"Fichier PDF introuvable"); + throw new SoapFault('0000', "Fichier PDF introuvable"); } $commandeM->update(array('dateEnvoi'=> date('YmdHis')), 'id='.$id); diff --git a/scripts/jobs/getKbis.php b/scripts/jobs/getKbis.php index d730e295..9f639fb4 100644 --- a/scripts/jobs/getKbis.php +++ b/scripts/jobs/getKbis.php @@ -356,8 +356,6 @@ if ( $opts->commandes ) echo "Téléchargement du kbis...\n"; infogreffeKbis($opts->visu); - //Lancer WKHTMLTOPDF pour le PDF - } elseif ( !$opts->visu ) { /**************************************************