php
2016-05-21 4 views 1 likes 
1

DOMPDFを使用して請求書を作成しています。私はいくつかのdivを横に並べる必要があります。 float要素が機能していません。私は列1DOMPDFには2つのdivが並んでいますか? PHP

以下
<?php 
require_once "dompdf/dompdf_config.inc.php"; 

$dompdf = new DOMPDF(); 

$html =' 
<html> 
<link type="text/css" href="pdf.css" rel="stylesheet"/> 
<body> 

<div class="columns"> 
    <div class="red" >Column 1</div> 
    <div class="grey">Column 2</div> 
    <div class="red" >Column 3</div> 
</div> 
<div class="clear"></div> 

</body> 
</html> 
'; 

$dompdf->load_html($html); 
$dompdf->render(); 

//$dompdf->stream("hello.pdf"); 

$dompdf->stream('my.pdf',array('Attachment'=>0)); 

?> 

横に2列を取得しようとしていますCSS

div.columns  { width: 50%; } 
div.columns div { width: 50%; height: 100px; float: left; } 
div.grey   { background-color: #cccccc; } 
div.red   { background-color: #e14e32; } 
div.clear   { clear: both; } 

答えて

0

は、外部スタイルシートのパスに追加され:

$dompdf->set_base_path('(FilePath)/pdf.css'); 

を後:$dompdf->render();

。なお、 CSSセレクタはdompdfで大文字と小文字を区別します。

読むhttp://code.google.com/p/dompdf/wiki/CSSCompatibilityやGitのhttps://github.com/dompdf/dompdf/wiki/CSSCompatibility

DOMPDF doesn't work with external css file

CSS not working with DOMPDF

を参照してください。
関連する問題