With view PDF generated with Laravel-dompdf on Viewer.js?

Asked

Viewed 514 times

0

I have an app Laravel that generates reports in PDF according to parameters received from a form via POST and would like to view the files generated with the viewer.js without having to save the files in directory and the function used to generate the PDF is:

public function generateReport(Request $request){
    $dataset = Report::where('idfilial', '=', $request->idfilial)
               ->whereBetween('datamovimento', [$request->datainicial, $data->datafinal])
               ->get();
    $pdf = \App::make('dompdf.wrapper');
    $pdf->loadHtml(view('report.pdf', compact('dataset')));
    return $pdf->stream();
}
  • With this plugin no, it only accepts the path of a disk file, as explained in its instruction documentation

  • 1

    I’ve already found some examples using an Encode Base64, something like this: Viewer.html? file=data:application/pdf;Base64,Jvberi0xljqxxxxx

  • Paste here the links of the examples!

  • because of the amount of characters, I added the example link to a Docs.google that you can access by this link: https://docs.google.com/document/d/1t01HuDEC01QulzTXw_jRqmoEA3C7M1LfLlv7b45f7f4/edit?usp=sharing

  • A Base64 from Hello Word is one thing a large document will not support

  • However, if you open the example link that sends you and replace the Encode Base64 with the Encode Base64 of any other pdf it works. But if I do it the same way in my project it doesn’t work. So I think it’s just a matter of configuration, but I didn’t find anything in the documentation

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.