2013-04-05 54 views
1

这是我的代码HTML图像在PDF不打印

<?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,当我呼应$输出,我可以看到广场在图像上,但在我生成的pdf只有图像正在打印,正方形不是?

有人有什么想法?

+1

请问您可以添加调试功能来查看错误并进行编辑吗? '$ mpdf-> debug = true;' – soumer 2013-04-05 11:30:45

回答

0

更改<span>标签为<div>标签,它应该工作。

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

+0

我也能够生成正方形,但宽度和高度不能在pdf中工作。 – Dhar 2013-04-05 16:04:02