Вопрос

I am trying to get MPDF to correctly print divs with overflow:hidden. I've read their documentation up and down and tried various things. No luck. Per mpdf, block elements with overflow:hidden must have position:absolute or position:fixed set. That is fine when you printing just one div. The issue comes up when i try to nest divs and need the inner one to clip text. Here's what I mean:

This prints out fine

$html = <<< EOM
<div style='width:300px;height:100px;position:absolute;overflow:hidden;border:1px solid black;'>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.  
</div>
$html = <<< EOM

This does not

$html = <<< EOM
<div style='border:1px solid red;position:relative;'>
<div style='width:300px;height:100px;position:absolute;overflow:hidden;border:1px solid black;'>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.  
</div>
</div>
$html = <<< EOM

The php script is simple

include("mpdf.php");
$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$mpdf->Output();

As you can see the only difference is that one div is inside another one. Has anyone figured out how to do this?

Это было полезно?

Решение

In mpdf you can't use overflow: hidden; on nested divs. overflow: hidden; can only be used on top level elements.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top