加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – WKHTMLtoPDF头文件内容未以PDF格式显示

发布时间:2020-12-13 22:35:37 所属栏目:PHP教程 来源:网络整理
导读:我试图在第一页上隐藏页眉页码使用这个例子我找到了 here.这只有在我使用footer-html时才有效,如果我用header-html它没有显示/隐藏任何东西.最初我试图增加这个 solution,它也使用footer-html,但由于我无法让它在标题中工作,我一直在搜索.我试过它有没有’he
我试图在第一页上隐藏页眉页码使用这个例子我找到了 here.这只有在我使用footer-html时才有效,如果我用header-html它没有显示/隐藏任何东西.最初我试图增加这个 solution,它也使用footer-html,但由于我无法让它在标题中工作,我一直在搜索.我试过它有没有’header-center’=> ‘[[page]]’以防万一与header-html一起使用会导致冲突.最近有人能够在标题中使用它吗?我正在使用PHPWKHTMLtoPDF包装器版本1.2.6-dev,如果这有助于WKHTMLtoPDF的最新版本,因为最新版本的PHPWKHTMLtoPDF使用名称空间,我们正在使用CodeIgniter 2.x-dev,它不支持它们(或打得好不能记住).
// Create document PDF
    $pdf = new $this->wkhtmltopdf;

    // Locate WkHtmlToPdf executable for Windows
    if( $pdf->getIsWindows() ) 
    {
        $pdf->setOptions( array( 'binPath' => 'C:Program Fileswkhtmltopdfbinwkhtmltopdf.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__) . '..viewswkhtmltopdfheader.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'
    ) );
您需要添加<!DOCTYPE html>到头文件,WKHTMLtoPDF issue #46版本0.12

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读