protected function WkhtmltopdfController::buildShellCommand in wkhtmltopdf 2.0.x
Builds the shell command including parameters
Parameters
string $url: The absolute url that we're generating a pdf of
string $drupal_file_path: The drupal file path where the pdf will be generated
Return value
string The full shell command including parameters
1 call to WkhtmltopdfController::buildShellCommand()
- WkhtmltopdfController::createFile in src/
Controller/ WkhtmltopdfController.php - Actually sends the shell command, and returns after the pdf file has been created
File
- src/
Controller/ WkhtmltopdfController.php, line 171
Class
- WkhtmltopdfController
- A Controller to generate PDFs and return them as a binary reponse.
Namespace
Drupal\wkhtmltopdf\ControllerCode
protected function buildShellCommand($url, $drupal_file_path) {
$binary = $this->settings
->get('wkhtmltopdf_bin');
if (empty($binary)) {
$this->logger
->error('wkhtmltopdf binary path has not been set in the configuration');
throw new HttpException(500, 'An error occurred generating the pdf.');
}
$physical_file_path = $this->filesystem
->realpath($drupal_file_path);
$arguments = $this
->getCommandLineArguments();
$command = $binary;
foreach ($arguments as $argument => $argument_value) {
if (empty($argument_value)) {
$command .= ' --' . $argument;
}
else {
$command .= ' --' . $argument . ' ' . escapeshellarg($argument_value);
}
}
$command .= ' ' . $url . ' ' . $physical_file_path;
return $command;
}