CakePdf\Pdf\Engine\WkHtmlToPdfEngine::_getCommand PHP Method

_getCommand() protected method

Get the command to render a pdf
protected _getCommand ( ) : string
return string the command for generating the pdf
    protected function _getCommand()
    {
        $binary = $this->config('binary');
        if ($binary) {
            $this->_binary = $binary;
        }
        if (!is_executable($this->_binary)) {
            throw new Exception(sprintf('wkhtmltopdf binary is not found or not executable: %s', $this->_binary));
        }
        $options = ['quiet' => true, 'print-media-type' => true, 'orientation' => $this->_Pdf->orientation(), 'page-size' => $this->_Pdf->pageSize(), 'encoding' => $this->_Pdf->encoding(), 'title' => $this->_Pdf->title(), 'javascript-delay' => $this->_Pdf->delay(), 'window-status' => $this->_Pdf->windowStatus()];
        $margin = $this->_Pdf->margin();
        foreach ($margin as $key => $value) {
            if ($value !== null) {
                $options['margin-' . $key] = $value . 'mm';
            }
        }
        $options = array_merge($options, (array) $this->config('options'));
        $command = $this->_binary;
        foreach ($options as $key => $value) {
            if (empty($value)) {
                continue;
            } elseif ($value === true) {
                $command .= ' --' . $key;
            } else {
                $command .= sprintf(' --%s %s', $key, escapeshellarg($value));
            }
        }
        $footer = $this->_Pdf->footer();
        foreach ($footer as $location => $text) {
            if ($text !== null) {
                $command .= " --footer-{$location} \"" . addslashes($text) . "\"";
            }
        }
        $header = $this->_Pdf->header();
        foreach ($header as $location => $text) {
            if ($text !== null) {
                $command .= " --header-{$location} \"" . addslashes($text) . "\"";
            }
        }
        $command .= " - -";
        return $command;
    }