title: How to generate PDF from an active View Laravel
body: <p>I have a search box when user input roll no, it returns the specific student result. I want to generate PDF of that searched data, that data is in table.
  <a href="https://i.stack.imgur.com/hZEbo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hZEbo.png" alt="enter image description here" /></a>
  <strong>Main Question : I want to generate PDF for the result of student who has searched for his/her data, so how to generate PDF for that current student result.</strong></p>
  <p><strong>Print/PDF Generator Button:</strong></p>
  <pre><code> &lt;a href=&quot;{!! url('/getPDF') !!}&quot;&gt;Print&lt;/a&gt;
  </code></pre>
  <p><strong>PDFController:</strong></p>
  <pre><code>class PDFController extends Controller
  {
      public function getPDF(Request $request){
              // I want some code here to get the current student result so that I can generate pdf for the current student
              $pdf = PDF::loadView('results.single');
              return $pdf-&gt;stream('result.pdf');
      }
  }
  </code></pre>
  <p><strong>SearchController:</strong></p>
  <pre><code>class ResultsSearchController extends Controller
  {
      public function search()
      {
          $keyword = Input::get('keyword');
          $row = Student::where('rollno',$keyword)-&gt;first();
          $rollno = $row['rollno'];
          if($keyword == $rollno){
              return View::make('results.single')
              -&gt;with('search',Student::where('rollno',$keyword)
              -&gt;get())-&gt;with('keyword',$keyword);
          }else{
              return view('errors.404');
          }
      }
  }
  </code></pre>
  <p><strong>Routes.php:</strong></p>
  <pre><code>Route::get('/getPDF', 'PDFController@getPDF');
  </code></pre>
  <p>PS : I am using <a href="https://github.com/barryvdh/laravel-dompdf" rel="nofollow noreferrer">https://github.com/barryvdh/laravel-dompdf</a></p>