/** * @return null|string */ protected function compileVariablesOptions() { $paperSize = ['orientation' => $this->getOrientation(), 'format' => $this->getFormat()]; if ($margin = $this->getMargin()) { $paperSize['margin'] = $margin; } if ($this->getWidth() && $this->getHeight()) { $paperSize['width'] = $this->getWidth(); $paperSize['height'] = $this->getHeight(); unset($paperSize['format']); } $indents = ' '; $script = parent::compileVariablesOptions(); $script .= 'page.paperSize = {' . PHP_EOL; foreach ($paperSize as $key => $value) { $script .= $indents . $key . ': ' . (is_scalar($value) ? '"' . $value . '"' : json_encode($value)) . ',' . PHP_EOL; } if ($header = $this->getHeader()) { $script .= $indents . 'header: {' . PHP_EOL; $script .= $indents . $indents . 'height: "' . $header['height'] . '",' . PHP_EOL; $script .= $indents . $indents . 'contents: ' . $header['contents'] . PHP_EOL; $script .= $indents . '},' . PHP_EOL; } if ($footer = $this->getFooter()) { $script .= $indents . 'footer: {' . PHP_EOL; $script .= $indents . $indents . 'height: "' . $footer['height'] . '",' . PHP_EOL; $script .= $indents . $indents . 'contents: ' . $footer['contents'] . PHP_EOL; $script .= $indents . '},' . PHP_EOL; } $script .= '};' . PHP_EOL; return $script; }