首页 > 解决方案 > Create pdf for signature list using Laravel and dompdf

问题描述

I'm stuck on a problem that I thought should be straightforward, but dompdf refuses to make my pdf as I want it. I want a pdf that my end user should print out containing a list with users with their names and a line where they should sign. Something like this:

Picture showing how I want it to look

I'm trying to do it like this:

<style>
    .lineContainer div {height: 30px;} 
    .nounderscore {border-bottom: 0px;float:left;}
    .underscore {border-bottom: 1px solid #000; overflow: hidden;}
</style>

@foreach($users as $user)
    <div class="lineContainer">
        <div class="nounderscore">{{$user->name}}</div>
        <div class="underscore"></div>
    </div>
@endforeach

This works fine when rendered as html, but when I use it for a pdf file it ends up with my underline starting from the far left end of the page, so also the names are underlined. Any ideas how to do this in a way that works with dompdf?

标签: laraveldompdflaravel-8

解决方案


<style>
li{
  padding-bottom: 25px;
  list-style: none;
}
.line{
  padding-right: 15em;
  margin: 0 1em;
  border-bottom: 1px solid grey;
}

</style>
<ul>
@foreach($users as $user)
    <li>{{$user->name}}<span class="line"></span></li>
@endforeach
</ul>

静态数据答案预览: https ://jsfiddle.net/wz1vpsnx/


推荐阅读