0
votes

My html to pdf conversion using wkhtmlpdf working fine without the <style> tag but when I include the style tag it's not working that means not generating the pdf some one help me to solve this issue or let me know how to include my style.css in this format.

1

1 Answers

0
votes

The way I handle this is as follows--

<?php
// create some HTML content
    $html = '<!DOCTYPE html><html><head>
    <style>
        body {
            margin:     0;
            padding:    0;
        }
        ...
    </style></head><body>
    <!-- Your body content -->
    </body></html>';

$options = array(
                "no-outline",
                "binary"                    => "/usr/local/bin/wkhtmltopdf",
                "margin-top"                => ".25in",
                "margin-right"              => ".25in",
                "margin-bottom"             => ".55in",
                "margin-left"               => ".25in",
                "zoom"                      => 1
            );

$footer = '<!DOCTYPE html><html><head></head><body>...</body></html>';

$page_options = array('footer-html' => $footer);
$pdf->addPage($html, $page_options);

$pdf->saveAs('MY_PDF_NAME.pdf');

Hope this helps!

Best,

-Rush