0
我使用wkhtmltopdf生成pdf文件,我需要设置不同的选项到 不同的页面。Mikehaertl wkhtmltopdf为不同的页面设置不同的选项
例如:
$pdf->addPage('http://frontbeta/')->setOptions(['orientation' => 'landscape']);
$pdf->addPage('http://backbeta/');
所以,第1页和肖像orientaion到第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对象。那么我该如何改变功能呢?
这是事实,但只是作为一个全局选项,整个文件。 AFAIK,目前(可惜)没有选择wkhtmltopdf设置页面级别的方向。使用CSS旋转页面有一些可能性(我现在正在尝试),但只有在最简单的情况下才可能满足。有官方功能请求,在这里:https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1564。看看你是否可以帮助。 – userfuser