Skip to content

Instantly share code, notes, and snippets.

@kolomiec-valeriy
Created March 18, 2019 13:27
Show Gist options
  • Save kolomiec-valeriy/bc1b8a5754a830e0e8a16e856a3ffd85 to your computer and use it in GitHub Desktop.
Save kolomiec-valeriy/bc1b8a5754a830e0e8a16e856a3ffd85 to your computer and use it in GitHub Desktop.
<?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