图像上的HTML不以pdf格式打印

时间:2013-04-05 11:13:15

标签: php html mpdf

这是我的代码

<?php
class Diagram
{
function outLet()
{
    $boothsizer = 3;

    if($boothsizer ==  3){
        $cellWidth = '112px';
        $cellHeight = '52px';
        $innerDivElectricTop = '41px'; 
        $innerDivElectricLeft = '110px';    
        $backgroundImage = 'url(booth_top_images/5X20TOP.jpg)';
        $width = '900px';
        $height = '225px';
        $sidewalls = 2;
        $backwalls = 6; 
    }
    else
    if($boothsizer ==  19)
    {
        $cellWidth = '144px';
        $cellHeight = '145px';
        $innerDivElectricTop = '105px'; 
        $innerDivElectricLeft =  '73px';    
        $backgroundImage = 'url(booth_top_images/10X10TOP.jpg)';
        $width = '599px';
        $height = '605px';
        $sidewalls = 3;
        $backwalls = 3;
    }

    $innerDivElectricWidth = $backwalls * $cellWidth;
    $innerDivElectricHeight = $sidewalls * $cellHeight;

    $output = '<div style="width:'.$width.'; height:'.$height.'; background-image:'.$backgroundImage.'">';

    $output .= '<div id="inner_div_electric" style="position: relative; top: '.$innerDivElectricTop.'; left: '.$innerDivElectricLeft.';width:'.$innerDivElectricWidth.';height:'.$innerDivElectricHeight.'">';

    for($i=1; $i<=$sidewalls; $i++)
    {
            for($j=1; $j<=$backwalls; $j++)
            {
                $output .= '<span class="droppable_class" style="width:'.($cellWidth-2).'; height:'.($cellHeight-2).'; border:1px solid red; float:left;display:inline-block;margin:0px;padding:0px;"></span>';

            }
    }

    $output .= '</div></div>';

    echo $output;


    include("test/mpdf/mpdf.php");
    $mpdf=new mPDF();   
    $mpdf->ignore_invalid_utf8 = true;
    $stylesheet = file_get_contents('appstyle_pdf.css');
    $mpdf->WriteHTML($stylesheet,1);
    $mpdf->WriteHTML($output);

    $comname = "vam";

    $name = "test/generated_pdfs/".str_replace(" ","-",$comname).".pdf";      
    $mpdf->Output($name,"F");   


}
}

$diag = new Diagram;
print $diag->outLet();
?>

在我的代码中,我试图在图像上生成一些正方形并尝试生成pdf,当我回显$ output时,我可以在图像上看到正方形,但在我生成的pdf中,只有图像是打印,正方形不是?

任何人的想法???

1 个答案:

答案 0 :(得分:0)

<span>代码更改为<div>代码,它应该有效。

不幸的是,我目前对解决方案没有任何解释。根据mpdf脚本<span>标签是enabledtags集合的一部分 - mpdf.php第23249行。所以我不完全确定为什么<div>有效且<span>没有