Whtmltopdf pagination without header or footer

I am using this php library wkhtmltopdf to generate pdf files. I am not using the most recent version yet, but there seems to be no improvement on this issue.

Using a full screen background image, I am facing the following problems:

  • Footer (and header) overlap pages (white background)
  • Cannot show pagination without header / footer (pagination will not work on pages)

Questions:

  • Is there a way to make the footer layer transparent?
  • Is there a way to show pagination without header / footer? (format page/pages

    )

Screenshot:

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();

      


Footer breakdown:

<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>

      

+3


source to share





All Articles