【发布时间】:2017-01-23 13:46:45
【问题描述】:
我正在使用 wkhtmltopdf 生成 pdf 文件,我需要设置不同的选项来 不同的页面。
例如:
$pdf->addPage('http://frontbeta/')->setOptions(['orientation' => 'landscape']);
$pdf->addPage('http://backbeta/');
因此,第 1 页为横向,第 2 页为纵向。 但是上面的代码将第一个选项设置为所有页面。
这里是生成pdf文件的函数:
protected function createPdf()
{
if ($this->_isCreated) {
return false;
}
$command = $this->getCommand();
$fileName = $this->getPdfFilename();
$command->addArgs($this->_options);
foreach ($this->_objects as $object) {
$command->addArgs($object);
}
$command->addArg($fileName, null, true); // Always escape filename
if (!$command->execute()) {
$this->_error = $command->getError();
if (!(file_exists($fileName) && filesize($fileName)!==0 && $this->ignoreWarnings)) {
return false;
}
}
$this->_isCreated = true;
return true;
}
在这里,它设置了 foreach 对象的选项。那么如何改变功能呢?
【问题讨论】:
标签: php