Created
March 18, 2019 13:27
-
-
Save kolomiec-valeriy/bc1b8a5754a830e0e8a16e856a3ffd85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Command; | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Console\Input\InputArgument; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use Symfony\Component\Process\Process; | |
/** | |
* Class PdfCreateCommand. | |
*/ | |
class PdfCreateCommand extends Command | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function configure() | |
{ | |
$this | |
->setName('pdf:create') | |
->setDescription('Create pdf file from url') | |
->addArgument('fileName', InputArgument::REQUIRED, 'The full file name') | |
->addArgument('url', InputArgument::REQUIRED, 'The url') | |
; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
$fileName = $input->getArgument('fileName'); | |
$url = $input->getArgument('url'); | |
$process = new Process("google-chrome --headless --disable-gpu --print-to-pdf={$fileName} {$url}"); | |
$process->run(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment