2017-06-06 53 views
0

我的html到pdf转换usig wkhtmlpdf工作正常,但没有<style>标签 但当我包含样式标签它不工作,这意味着不生成PDF有人帮我解决这个问题或让我知道如何包括我的style.css采用这种格式。Wkhtmltopdf转换

回答

0

我处理这是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'); 

希望这有助于方式!

最佳,

-Rush

+0

谢谢你,但它不工作,如果它能够使用风格相同的HTML –

+0

@Tijo是你看到了什么错误?可以请输出您的日志(首先清除它,然后运行脚本,然后粘贴输出) – Rushikumar

+0

没有错误显示那里它的工作正常没有风格标签 –