我正在使用DOM-PDF在LARAVEL 5.4中将HTML转换为PDF PDF转换很好。但是HTML页面设计令人不安。
showalumni.blade.php:
<div class="panel-body panel-body-com-m">
<a href="{{ URL('pdf/'.$showalumni->id) }}">Download to pdf</a>
<hr>
<label>Name : </label>
<input type="text" class="form-control1 control3" value="{{ $showalumni->name }}" required readonly readonly>
<label>Father's Name : </label>
<input type="text" class="form-control1 control3" value="{{ $showalumni->f_name }}" required readonly>
<label>Gender : </label>
<input type="text" class="form-control1 control3" value="{{ $showalumni->gender }}" required readonly>
<label>College : </label>
<input type="text" class="form-control1 control3" name="colleges_name" value="{{ $showalumni->showcollege->colleges_name }}" required readonly />
<label>Course : </label>
<input type="text" class="form-control1 control3" placeholder="Course name...." name="courses_name" value="{{ $showalumni->showcourse->coursename }}" required readonly />
</div>
路线:
Route::resource('registeredalumnies','Admin\RegisteredAlumniesController');
Route::get('pdf/{id}','Admin\RegisteredAlumniesController@download');
控制器:
public function show($id)
{
$showalumni = User::where('id',$id)->with('showcollege','showcourse')->first();
return view('Admin.showalumni',compact('showalumni'));
}
public function download($id)
{
$showalumni = User::where('id',$id)->with('showcollege','showcourse')->first();
$pdf = PDF::loadView('Admin.showalumni', compact('showalumni'));
return $pdf->stream('invoice.pdf');
}
转换后的PDF为: Previous Post
答案 0 :(得分:0)
您可以尝试使用内联css,但是这里要注意的重要一点是,您不应该使用应用程序或其他刀片文件扩展showalumni.blade.php,因为在大多数情况下,当我们从另一个文件扩展刀片文件时,导入主刀片中包含的部分可能会造成障碍。