mirror of
https://github.com/there4/markdown-resume.git
synced 2024-12-03 08:59:35 -05:00
Merge pull request #84 from danielklim/danielklim/pdfcommand-arg-passthrough
Pass command line args to wkhtmltopdf to enable better formatting
This commit is contained in:
commit
d4cfc4cdad
@ -31,6 +31,25 @@ class PdfCommand extends HtmlCommand
|
|||||||
InputOption::VALUE_REQUIRED,
|
InputOption::VALUE_REQUIRED,
|
||||||
'Which of the templates to use'
|
'Which of the templates to use'
|
||||||
)
|
)
|
||||||
|
->addOption(
|
||||||
|
'htmlonly',
|
||||||
|
'H',
|
||||||
|
InputOption::VALUE_NONE,
|
||||||
|
'Only render interim HTML (don\'t run wkhtmltopdf)'
|
||||||
|
)
|
||||||
|
->addOption(
|
||||||
|
'keephtml',
|
||||||
|
'k',
|
||||||
|
InputOption::VALUE_NONE,
|
||||||
|
'Keep interim HTML'
|
||||||
|
)
|
||||||
|
->addOption(
|
||||||
|
'pdfargs',
|
||||||
|
'p',
|
||||||
|
InputOption::VALUE_REQUIRED,
|
||||||
|
'Passthrough arguments for wkhtmltopdf',
|
||||||
|
'--dpi 300 -s Letter'
|
||||||
|
)
|
||||||
->addOption(
|
->addOption(
|
||||||
'output',
|
'output',
|
||||||
'o',
|
'o',
|
||||||
@ -48,6 +67,9 @@ class PdfCommand extends HtmlCommand
|
|||||||
$template = $input->getOption('template');
|
$template = $input->getOption('template');
|
||||||
$pdfSource = join(DIRECTORY_SEPARATOR, array($destination, '.tmp_pdf_source.html'));
|
$pdfSource = join(DIRECTORY_SEPARATOR, array($destination, '.tmp_pdf_source.html'));
|
||||||
$optFilename = $input->getOption('output');
|
$optFilename = $input->getOption('output');
|
||||||
|
$htmlonly = $input->getOption('htmlonly');
|
||||||
|
$keephtml = $input->getOption('keephtml');
|
||||||
|
$pdfargs = $input->getOption('pdfargs');
|
||||||
|
|
||||||
$destFilename = join(DIRECTORY_SEPARATOR, array($destination, pathinfo($source, PATHINFO_FILENAME) . '.pdf'));
|
$destFilename = join(DIRECTORY_SEPARATOR, array($destination, pathinfo($source, PATHINFO_FILENAME) . '.pdf'));
|
||||||
|
|
||||||
@ -82,11 +104,24 @@ class PdfCommand extends HtmlCommand
|
|||||||
// Save to a temp destination for the pdf renderer to use
|
// Save to a temp destination for the pdf renderer to use
|
||||||
file_put_contents($pdfSource, $rendered);
|
file_put_contents($pdfSource, $rendered);
|
||||||
|
|
||||||
|
// command that will be invoked to convert html to pdf
|
||||||
|
$cmd = "wkhtmltopdf $pdfargs $pdfSource $destFilename";
|
||||||
|
|
||||||
// Process the document with wkhtmltopdf
|
// Process the document with wkhtmltopdf
|
||||||
exec('wkhtmltopdf --dpi 300 ' . $pdfSource .' ' . $destFilename);
|
if(!$htmlonly)
|
||||||
|
exec($cmd);
|
||||||
|
|
||||||
// Unlink the temporary file
|
// Unlink the temporary file
|
||||||
|
if(!($htmlonly || $keephtml))
|
||||||
unlink($pdfSource);
|
unlink($pdfSource);
|
||||||
|
else
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
"Keeping interim HTML: <info>%s</info>",
|
||||||
|
$pdfSource
|
||||||
|
),
|
||||||
|
$this->app->outputFormat
|
||||||
|
);
|
||||||
|
|
||||||
$output->writeln(
|
$output->writeln(
|
||||||
sprintf(
|
sprintf(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user