how to convert html to pdf by DOM-PDF with proper HTML design

Posted 7 months ago by vinubangs

I am using DOM-PDF for converting HTML to PDF in LARAVEL 5.4 PDF conversion is good. But HTML page design is disturbing. Means After click on "Download to pdf", HTML is converting into PDF. But HTML design in PDF is not in proper way.

showalumni.blade.php:

@extends('layouts.mainsectioninner')

@section('content')
<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>
@endsection

route:

Route::resource('registeredalumnies','Admin\RegisteredAlumniesController');
Route::get('pdf/{id}','Admin\[email protected]');

Controller:

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');
}

Please sign in or create an account to participate in this conversation.