Home > front end >  How to print pdf by range date in laravel?
How to print pdf by range date in laravel?

Time:11-01

I am looking for a way to print a PDF file in my laravel application. I have only found on the internet solutions to print the PDF in the web browser. Is there a package that allows me to view a PDF directly in a native Control webBrowser? Thanks in advance!

CodePudding user response:

If you just need to output the pdf directly in the browser - and not referring to a pdf generation library - you can output the correct pdf headers and then print the file.

for example, see this code snippet:

$file = 'filename.pdf';
$filename = 'filename.pdf';

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');

@readfile($file);

CodePudding user response:

https://github.com/niklasravnsborg/laravel-pdf

This package allows you to use the "stream" function to return the pdf back to the browser without downloading it.

  • Related