我正在尝试隐藏第一页上的页眉页码,使用这个例子我找到了here。这只在我和footer-html一起使用时有效,如果我和header-html一起使用它不会显示/隐藏任何东西。最初我试图扩充这个solution,它也可以使用footer-html,但是因为我不能让它在页眉中工作,所以我一直在搜索。我已经尝试过使用和不使用'header-center‘=> '[page]’,以防与header-html一起使用会导致冲突。最近有没有人能让它在标题中起作用?我使用PHPWKHTMLtoPDF包装器版本1.2.6-dev,如果这对最新版本的WKHTMLtoPDF有帮助的话,因为最新版本的PHPWKHTMLtoPDF使用名称空间,而我们使用的是CodeIgniter 2.x-dev,它不支持它们(或者play well不记得)。
// Create document PDF
$pdf = new $this->wkhtmltopdf;
// Locate WkHtmlToPdf executable for Windows
if( $pdf->getIsWindows() )
{
$pdf->setOptions( array( 'binPath' => 'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe',
'no-outline',
'encoding' => 'UTF-8',
'margin-top' => 30,
'margin-right' => 20,
'margin-bottom' => 30,
'margin-left' => 20,
// Default page options
'disable-smart-shrinking',
'user-style-sheet' => 'pdf.css',
'header-html' => dirname(__FILE__) . '\..\views\wkhtmltopdf\header.html'
) );
}
// Generate document fields
$docInputs = $this->generate_inputs( $inputs, json_decode( $this->load->file( APPPATH . '/mapping/' . $document['mapping'], TRUE ), TRUE ) );
// Merge document fields into HTML exported Word files
$docHTML = $this->parser->parse( 'docs/' . $document['html'], $docInputs, TRUE );
// Add HTML as page, along with option for page header
$pdf->addPage( $docHTML, array( 'header-center' => '[[page]]',
'header-spacing' => '10',
'header-font-name' => 'Times New Roman'
) ); 发布于 2015-01-09 03:24:48
对于版本0.12,您需要将<!DOCTYPE html>添加到头文件WKHTMLtoPDF issue #46中
发布于 2016-12-05 23:24:10
我之所以发布这个答案,是因为这件事发生在我身上,这也可能是一个原因。
我也注意到如果你将标题css设置为这个。它不会显示标题。
html{
width: 100%;
height: 100%;
}https://stackoverflow.com/questions/27847443
复制相似问题