没有页眉或页脚的Wkhtmltopdf分页

时间:2014-10-23 09:57:36

标签: php wkhtmltopdf

我正在使用此php wkhtmltopdf库来生成pdf。我还没有使用最新版本,但似乎没有对此问题进行任何改进。

使用整页背景图片,我遇到了以下问题:

  • 页脚(和页眉)重叠页面(白色背景)
  • 无页眉/页脚无法显示分页(页脚分页赢得了页面上的工作)

问题:

  1. 有没有办法让页脚背景透明?
  2. 有没有办法在没有页眉/页脚的情况下显示分页? (page/pages格式)
  3. 截图:

    enter image description here


    PHP:

    $pdf_options = array(
        'binPath'        => 'wkhtmltopdf-amd64',
        'encoding'       => 'UTF-8',
        'dpi'            => 96,
        'margin-top'     => '0mm',
        'margin-right'   => '0mm',
        'margin-bottom'  => '0mm',
        'margin-left'    => '0mm',
        'footer-html'    => $tmpDir.'/footer.html',
        'header-spacing' => 0,
        'footer-spacing' => -20,
        'no-outline'
    );
    
    
    $page_options = array(
        'disable-smart-shrinking'
    );
    
    
    $pdf = new WkHtmlToPdf($pdf_options);
    
    $pdf->setPageOptions($page_options);
    
    $pdf->addPage($tmpDir.'/body.html');
    
    
    $renderPdf = $pdf->send();
    

    页脚分页:

    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
            <script>
            function pagination()
            {
                var vars = {};
                var x = document.location.search.substring(1).split('&');
    
                for (var i in x)
                {
                    var z = x[i].split('=', 2);
                    vars[z[0]] = unescape(z[1]);
                }
    
                var x = ['frompage','topage','page','webpage','section','subsection','subsubsection'];
    
                for (var i in x)
                {
                    var y = document.getElementsByClassName(x[i]);
    
                    for (var j = 0; j < y.length; ++j)
                    {
                        y[j].textContent = vars[x[i]];
                    }
                }
            }
            </script>
        </head>
    
        <body onload="pagination()">
    
            <div id="pagination">
                <span class="page"></span>/<span class="topage"></span>
            </div>
    
        </body>
    </html>
    

0 个答案:

没有答案