2016-12-18 19 views
2

現在、HTMLをPDFに変換するmikehaertl/phpwkhtmltopdfパッケージを実行しています。デモデータを使用して、私は、PDFに正しいページ寸法をレンダリングする際に問題があるようです。私はページをA4レイアウトで塗りつぶす必要がありますが、何らかの理由ではるかに小さい解像度の出力を得ています。私は気づいていない設定があると思うか、HTML/CSSに何か不足していると思いますか?PHP HTMLからPDF mikehaertl/phpwkhtmltopdfページサイズの問題

enter image description here

私が実行しているPHPさ:getOrderPrint方法は、HTML以下returnin正しくあり

$pdf = new mikehaertl\wkhtmlto\Pdf(
        array(
        'binary' => '/usr/local/bin/wkhtmltopdf', 
         'no-outline',   // Make Chrome not complain 
          'margin-top' => 0, 
          'margin-right' => 0, 
          'margin-bottom' => 0, 
          'margin-left' => 0, 

          // Default page options 
          'disable-smart-shrinking' 

       ) 
       ); 
       $pdf->addPage($this->getOrderPrint($objectId)); 


// Save the PDF 
       $pdf->saveAs(dirname(__FILE__).'/test.pdf'); 

<!DOCTYPE html> 
<head> 

    <style type="text/css"> 
    body { 
     margin:  0; 
     padding: 0; 
     width:  21cm; 
     height:  29.7cm; 
    } 

    /* Printable area */ 
    #print-area { 
     position: relative; 
     top:  1cm; 
     left:  1cm; 
     width:  19cm; 
     height:  27.6cm; 

     font-size:  10px; 
     font-family: Arial; 
    } 

    #header { 
     height:  3cm; 

     background: #ccc; 
    } 
    #footer { 
     position: absolute; 
     bottom:  0; 
     width:  100%; 
     height:  3cm; 

     background: #ccc; 
    } 
    </style> 
</head> 
<body> 

<div id="print-area"> 
    <div id="header"> 
    This is an example headernbmv. 
    </div> 
    <div id="content"> 
    <h1>Demo</h1> 
    <p>This is example content</p> 
    </div> 
    <div id="footer"> 
    This is an example footer. 
    </div> 
</div> 

</body> 
</html> 

答えて

0

は、あなたのwkhtmltopdfオプションに'page-size' => 'A4'を追加してください。